Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Jilebi Nimki
//g++ 7.4.0 #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;} 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 "; s1->get(); cout<<" & a pair cost Tk "; s1->cost(); cout <<".\n"; cout<<"Jilebi is "; s2->get(); cout<<" & costs Tk "; s2->cost(); cout<<endl; return 0; }
run
|
edit
|
history
|
help
0
good triplet
Gauss 4x4 reducido
TemplateDoubly
HeapSort
ww999
WeekAgenda2
NWD, algorytm Euklidesa
p30
Even Odd using Functions
map_find