size of an object of a class
-
there is a class, say
class a
{
int i,j,k;
}then, another class is derived as,
class b:a
{
int a,b,c;
}now how many locations in the memory the object of class b will occupy, i mean wat will be the size of object of class b. 3 or 6 ??? i have tried to use
sizeof
operator. But the compiler is giving error ! -
there is a class, say
class a
{
int i,j,k;
}then, another class is derived as,
class b:a
{
int a,b,c;
}now how many locations in the memory the object of class b will occupy, i mean wat will be the size of object of class b. 3 or 6 ??? i have tried to use
sizeof
operator. But the compiler is giving error !First, this code doesn't compile because you have a data member with the same name of the class "b" Second, I think you want to know how many data members are there in the class B. There are 6 data members i, j, k, a, b and c. But you can only access a, b and c from the class B because i, j and k are private members of the class "a". If you really want to know the size in bytes, http://blogs.msdn.com/cbrumme/archive/2003/04/15/51326.aspx[^] http://blogs.msdn.com/mab/archive/2006/04/24/582666.aspx[^]
Eslam Afifi
-
First, this code doesn't compile because you have a data member with the same name of the class "b" Second, I think you want to know how many data members are there in the class B. There are 6 data members i, j, k, a, b and c. But you can only access a, b and c from the class B because i, j and k are private members of the class "a". If you really want to know the size in bytes, http://blogs.msdn.com/cbrumme/archive/2003/04/15/51326.aspx[^] http://blogs.msdn.com/mab/archive/2006/04/24/582666.aspx[^]
Eslam Afifi
Thanx
-
Thanx
You're welcome.
Eslam Afifi