Hi,
What is the memory layout of an object, and the derived object.
For example :
class A
{
private:
int prv_data;
protected:
int pro_data;
public:
int pub_data;
A(){prv_data = 10;}
void Aprint();
};
class B : public A
{
int pro_data;
public:
void Bmember1();
void Bprint();
};
Does it depend on the compiler ?
int main()
{
B b;
int *ptr;
ptr = (int *)&b;
*ptr = 1000;
ptr++;
*ptr = 2000;
ptr++;
*ptr = 3000;
ptr++;
*ptr = 4000;
return 0;
}
is setting only the private element of class A to 1000, rest are not
being set.