Connecting Tech Pros Worldwide Help | Site Map

How is the size of a class computed ?

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

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, 01:59 PM
Sharad Kala
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Postpone creation of attributes until needed Frank Millman answers 23 June 13th, 2007 03:35 PM
Class/struct and Marshal.SizeOf SB answers 6 November 16th, 2005 09:22 PM
Is C99 the final C? Michael B. answers 193 November 14th, 2005 04:46 PM
Getting (and setting) a style value from a element that use a class Michael Bierman answers 21 July 23rd, 2005 08:15 PM