 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
void
account::statement(ostream &o) {
|
|
o <<"Account Statement"
<<endl;
|
|
o <<" name = " <<name <<endl;
|
|
o <<" balance = " <<balance
<<endl;
|
|
}
|
|
void
checking::statement(ostream &o) {
|
|
o <<"Checking "; account::statement(o);
|
|
o <<" charges = " <<charges
<<endl;
|
|
}
|
|
void
student::statement(ostream &o) {
|
|
o <<"Student "; checking::statement(o);
|
|
o <<" school = " <<school
<<endl;
|
|
}
|
|
ostream
&operator<<(ostream &o, account &a) {
|
|
a.statement(o); return (o);
|
|
}
|
|
app:
student smith("Kyle
smith", 5000, "UT");
|
|
account
&ra(smith); //reference
|
|
account*
pa(&smith); //pointer
|
|
cout
<<ra <<*pa; //both use the “student
|