Hello.
In general, there are 3 classes, one is abstract, the others are derivatives. In the abstract, a virtual function is described without implementation, and in the other two it is implemented. How to call the implemented function from each derived class in main ()?
Here is the code:
class components { public: virtual int solve(void) = 0; }; class componentsOne : public components { public: int result, x, y; componentsOne(int x, int y) { printf("Create object First"); printf("%d",solve(x, y)); } int solve(int x, int y) { return result = x+y; } }; class componentsTwo : public components { public: int result, x, y; componentsTwo(int x, int y) { printf("Create object First"); printf("%d",solve(x, y)); } int solve(int x, int y) { return result = x*x+y; } };
Thank you very much in advance!