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 sayHello(){
- cout << "Hello, " << name << "!" << endl;
- }
- };
- class Hi : public Hello{
- public:
- Hi(){
- }
- Hi(string n) : Hello(n){
- }
- void sayHi(){
- cout << "Hi, " << name << "!" << endl;
- }
- };
- int main(){
- Hi h("Sonic");
- h.sayHi();
- return 0;
- }
Add Comment
Please, Sign In to add comment