Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Jilebi Nimki
//g++ 7.4.0 //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; #include <iostream> #include <string> using namespace std; class Snack{ protected: int price, qty; string color; public: void set(int a, int b, string t) { price =a; qty= b; color=t;} string get(){return color;} virtual int cost() { return 0;} }; class Nimki : public Snack { public: int cost() { return price ;} }; class Jilebi : public Snack{ public: int cost() { return price *qty;} }; int main () { Nimki n; Jilebi j; Snack * s1=&n; Snack * s2=&j; s1->set(5,2,"Brown"); s2->set(10,1,"Red"); cout<<"Nimki is "; cout<<s1->get(); cout<<" & a pair cost Tk "; cout<<s1->cost(); cout <<".\n"; cout<<"Jilebi is "; cout<<s2->get(); cout<<" & costs Tk "; cout<<s2->cost(); cout<<endl; return 0; }
run
|
edit
|
history
|
help
0
Dulce enredo p1
Test 8(2020)
ExceptionWhat
CPP - Arrays - Ex.2
string probe
VecScalMultiOpLaod
Dar
HCF
Proyecto 1
big boom!