A lady behaves like a teacher in a classroom, mother or daughter in a home and
customer in a market. Here, a single person is behaving differently according to the
situations. Consider a above real-life example and which concept you will use in cpp.
Elaborate the concept.Explain in theory.
#include <iostream>
using namespace std;
class Lady {
public:
void info(){
cout<<"personal information:...";
}
};
class Teacher: public Lady
{
public:
void info()
{ cout<<"Personal information: teaching physics...";
}
};
class Mother: public Lady
{
public:
void info()
{ cout<<"Personal information: Mother...";
}
};
class Customer: public Lady
{
public:
void info()
{ cout<<"Personal information: buying...";
}
};
int main(void) {
Customer c = Customer();
c.info();
return 0;
}
Comments
Leave a comment