Connecting Tech Pros Worldwide Forums | Help | Site Map

How is the size of a class computed ?

Razvan
Guest
 
Posts: n/a
#1: Jul 22 '05
Hi !



How is the size of a class computed ?



Suppose I have the class:


class CTest
{
public:
CTest(void) {}
virtual ~CTest(){}
operator int() const {return 0;}
};


The class has no attributes. What should the sizeof (CTest) return ?
Is there a rule or is it completely system dependent ?





Regards,
Razvan

John Harrison
Guest
 
Posts: n/a
#2: Jul 22 '05

re: How is the size of a class computed ?



"Razvan" <mihai11@mailcity.com> wrote in message
news:15f19d61.0406220130.1b94b0f0@posting.google.c om...[color=blue]
> Hi !
>
>
>
> How is the size of a class computed ?
>
>
>
> Suppose I have the class:
>
>
> class CTest
> {
> public:
> CTest(void) {}
> virtual ~CTest(){}
> operator int() const {return 0;}
> };
>
>
> The class has no attributes. What should the sizeof (CTest) return ?
> Is there a rule or is it completely system dependent ?
>[/color]

It will not return zero. Apart from that it is system dependent.

john


Sharad Kala
Guest
 
Posts: n/a
#3: Jul 22 '05

re: How is the size of a class computed ?



"Razvan" <mihai11@mailcity.com> wrote in message
news:15f19d61.0406220130.1b94b0f0@posting.google.c om...[color=blue]
> Hi !
>
> The class has no attributes. What should the sizeof (CTest) return ?
> Is there a rule or is it completely system dependent ?[/color]

No, implementation defined.


Closed Thread