Connecting Tech Pros Worldwide Help | Site Map

How is the size of a class computed ?

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 22nd, 2005, 12:59 PM
Razvan
Guest
 
Posts: n/a
Default How is the size of a class computed ?

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

  #2  
Old July 22nd, 2005, 12:59 PM
John Harrison
Guest
 
Posts: n/a
Default 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


  #3  
Old July 22nd, 2005, 12:59 PM
Sharad Kala
Guest
 
Posts: n/a
Default 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.


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.