Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Hello{
- protected:
- string name;
- public:
- Hello(){
- name = "NoName";
- }
- Hello(string n){
- name = n;
- }
- void say(){
- cout << "Hello, " << name << "!" << endl;
- }
- };
- class Hi : public Hello{
- public:
- Hi(){
- }
- Hi(string n):Hello(n){
- }
- void say(){
- cout << "Hi, " << name << "!" << endl;
- }
- };
- int main(){
- Hello a("Amy");
- a.say();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment