How is the size of a class computed ?

R

Razvan

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
 
S

Sharad Kala

Razvan said:
Hi !

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

No, implementation defined.
 
J

John Harrison

Razvan said:
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 ?

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

john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top