How do I make this program in polymorphic form?
This is the code I'm working on
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#include <iostream>
using namespace std;
class store {
protected:
int x;
public:
char shelf()
{
char x;
cin >> x;
switch (x) {
case 'a':
cout << "Water Ghosts\n" << endl;
break;
case 'b':
cout << "Black Water\n" << endl;
break;
case 'c':
cout << "Gathering of Waters\n" << endl;
break;
default: cout << "sigh!\n" << endl;
}
return x;
};
};
class mother : public store {
public:
void shelf()
{
cout << "Pick abook " << endl;
}
};
class daughter : public mother {
public:
void books()
{
cout << "This ia a great book\n";
}
};
int main()
{
store bookshelf;
mother selectbook;
selectbook.shelf();
char option = bookshelf.shelf();
daughter book;
book.books();
system("pause");
}
|
Sorry, who is a mother? Who is a daughter?
Topic archived. No new replies allowed.