p->a initializes 'a' of base class, but which 'a' .......as data type are bind with an object not class, so from where it find 'a' of object o.
If p=&o is removed from the program, it is giving segmentation fault ?
I am very confused with all these behavior of compiler....
User Profile
Collapse
-
Problem of virtual function
# include<iostrea m>
using namespace std;
class one
{
public:
int a;
virtual void fun()
{
cout<<"\n In Base\t a ="<<a;
cout<<endl;
}
}o;
class two : public one
{
public :
int a;
void fun()
{
cout<<"\n In Derived\t a ="<<a;
}
}o1;
int...
No activity results to display
Show More
Leave a comment: