#include<iostream>
using namespace std;
class base
{
public:
virtual void fun() { cout <<"base"; } //this is
virtual function
void run() { fun();}
};
class der:public base // base class is
inherited
{
public:
void fun()
{ cout <<"derived"; }
};
int main()
{
der d;
d.run();
return 0;
}
output : derived
but when we remove virtual keyword it gives "base".
why?
i think virtual mechanism is done through only POINTER. Is this
write?
what mechanism is happening
any link about this
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.