Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- //Base class: Gives the stuff.
- class Mother
- {
- public:
- Mother();
- void sayname();
- };
- //Derived class: Inherit the stuff.
- class Daughter: public Mother //Inherit the members from the class Mother.
- {
- public:
- Daughter();
- };
- int main()
- {
- Mother mom;
- mom.sayname();
- Daughter girl;
- girl.sayname();
- return 0;
- }
- void Mother::sayname()
- {
- cout << "I am a roberts!" << endl;
- }
- Mother::Mother()
- {
- }
- Daughter::Daughter()
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement