Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
MoaJhalMury
//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 Mury{ protected: int price,qty; string color, taste; public: string getCol() const { return color;} string getTast() const { return taste;} void set(int a, int b, string p, string q) { price =a; qty=b; color= p; taste=q;} virtual int cost() =0;//pure virtual member function (PVF) void printcost() { cout<<this->getCol()<<",\t"; cout<<this->getTast()<<",\t"; cout<<" and costs Tk "; cout <<this->cost();//PVF can be called from abstract base class cout <<endl; } }; class Moa : public Mury{ public: int cost() { return (price * qty);} }; class JhalMury: public Mury { public: int cost(){ return price;} }; int main() { Moa m; JhalMury j; Mury * p1 = &m; Mury * p2 = &j; p1->set(5,2,"Red","Sweet"); p2->set(10,1,"White","Hot & Spicy"); cout<<" Moa is "; p1->printcost(); cout <<"\n"; cout<<" JhalMury is "; p2->printcost(); return 0; }
run
|
edit
|
history
|
help
0
unicodeのテスト
Zscore
vem de livezada
Test1
Microsoft Question - MaxEmployeeAttendence (any repititions are allowed)
Geometric Series
big boom!
string-Orderly words
Height of a binary tree
Sorting sort function stl in c++