Untitled
unknown
plain_text
2 years ago
1.5 kB
9
Indexable
/** * High leve class * With this kind of abstraction class, * we can change each time how Magshimim student does his homework. * */ class HomeWork{ public: virtual void doingHomeWork() const = 0; private: }; class BetterHomeWork: public HomeWork{ public: void doingHomeWork() const {cout << "put question in ChatGPT..." "Put in coding Environment..." "Done."; }; private: }; /** * High leve class * */ //class HomeWork{ // public: // void doingHomeWork() const {cout << "Me Program Me Getting Smart";}; // private: // int _field1; // int _field2; // int _field3; // int _field4; // int _field5; //}; class MagshimimStudent{ public: /** * What will happen if we would like to change the class HomeWork? * We can see that there's not much flexibility. * therefore, we will have two options. * 1. Inherit from HomeWork (but what if i dont want the whole class?) - low level class * 2. Make HomeWork Abstraction/Interface - high level class * */ void doHomeWork(const HomeWork& hw){ hw.doingHomeWork(); }; void enjoyLife() const {}; void OrSela() const {cout << "I Payed for lessons until 8pm!"; stayUntilEnd();}; void stayUntilEnd()const {}; private: }; int main() { MagshimimStudent stud; // HomeWork hw; BetterHomeWork hw; stud.doHomeWork(hw); return 0; }
Editor is loading...