192 Introduction to C++ Programming and Graphics
The resident class is defined and implemented as:
//--- RESIDENT CLASS
class resident : public student
{
public:
void payment()
{
tuition = 2567.65;
cout << " Resident tuition: " << tuition << endl;
};
private:
float tuition;
};
Note that the resident class is endowed with only one function and lacks a
constructor.
The non-resident class is defined and implemented as:
//--- NONRESIDENT CLASS
class nonresident : public student
{
public:
void payment()
{
tuition = 4879.99;
cout << " Non-resident tuition: " << tuition << endl;
};
private:
float tuition;
};
Note that the non-resident class is also endowed with only one function and
lacks a constructor.
The following main program declares students and pays their tuition
directly or through pointers:
int main()
{
resident R;
R.payment();
nonresident N;
N.payment();