Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
BreakfastMenu array
//g++ 7.4.0 #include <iostream> using namespace std; class Menu{ public: virtual void pack() const {cout<<"Default package has 2 parathas, 1 scrambled egg and 1 chai. It costs Tk 50.\n"; } }; class Pack1:public Menu{ public: void pack() const { cout<<"Package 1 has 2 rotis, 1 dal and 1 coffee. It costs Tk 80.\n";} }; class Pack2: public Menu{ public: void pack() const { cout<<"Package 2 has 3 slices of bread, jelly, banana and chai. It costs Tk 40.\n";} }; class Pack3:public Menu { public: void pack() const { cout<<"Package 3 has 1 plate of khichri. It costs Tk 60.\n";} }; int main() { Menu * list[4]; Menu * ptr; int choice; for (int i=0;i<4;i++) { cout <<"(1) Pack1 (2) Pack2 (3) Pack3 :\n"; cin>>choice; switch(choice) { case 1: ptr = new Pack1; break; case 2: ptr = new Pack2; break; case 3: ptr = new Pack3; break; default: ptr = new Menu; break; } list[i] = ptr; } for(int i=0;i<4;i++) list[i]->pack(); return 0; }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Triplet sum in array
MatrixVectorConversion
BinomialPoisson
odws
typecasting
tes
BFS Basic
BInTree Traversal
ThreadPool
better o/p of factor problem
Please log in to post a comment.