Polymorphism basic definition: allows dynamic binding, the function type to change during run time..Code:#include <iostream> using namespace std; class A { protected: int a ; int b; public: A() { a=10; b=100; } virtual int multiply()=0 ; }; class B:public A { public: int multiply(); int Divide() ; }; int B::Divide() { return b/a ; } int B::multiply() { return a*b ; } void main() { A *act= new B ; cout << act->multiply() ; cout << act->Divide() ;//this didn't work cout << act -> B::Divide() ;//also that doesn't work }
i wanted A to be able to use the divide function from the B class.
but I get a compiler error saying B is not a member object of a class, something like unambiguous access..
I don't get it... if act points to the class B or object of class B. should I not be able to use member functions of B?
Why does it not work and is there a way to solve this?
Thanks