P
Pallav singh
Hi All ,
in the below code i have created derived class object and in base
class we have virtual function.
i am using object slicing to copy only base part of it........ why is
not VTable getting updated Properly
Since in derived object's base part have address of derived class
virtual function address
Why its Not getting copied to base part with object slicing
is is behaving properly ?
#include <iostream>
using namespace std;
class Base
{
public :
virtual void func()
{ cout<<" I am inside Base "<<endl; }
};
class derived : public Base
{
public :
void func()
{ cout<<" I am inside Derived "<<endl; }
};
int main()
{
derived obj;
Base b = obj;
b.func();
return 0;
}
I am inside Base
Thanks
Pallav Singh
in the below code i have created derived class object and in base
class we have virtual function.
i am using object slicing to copy only base part of it........ why is
not VTable getting updated Properly
Since in derived object's base part have address of derived class
virtual function address
Why its Not getting copied to base part with object slicing
is is behaving properly ?
#include <iostream>
using namespace std;
class Base
{
public :
virtual void func()
{ cout<<" I am inside Base "<<endl; }
};
class derived : public Base
{
public :
void func()
{ cout<<" I am inside Derived "<<endl; }
};
int main()
{
derived obj;
Base b = obj;
b.func();
return 0;
}
I am inside Base
Thanks
Pallav Singh