sizeof operator doesn't work properly in call with static data members

From: balasubramaniam (balucit_at_yahoo.co.in)
Date: 11/30/03


Date: 29 Nov 2003 21:15:49 -0800

I comile the code in unix where sizof(int)=4
#include<iostream>
using namespace std;

class A
{
  int i;
  static int j;
};
int A::j = 10;
int main()
{
   cout<<sizeof(A)<<endl;

}
  both i,j are members of class A.so sizeof(A) should be printed as 8.
But i get 4.
      could anyone explain this behavior.



Relevant Pages

  • Re: Linux Sys Calls - int 80h
    ... load the parameters in the required registers and make the "int 0x80" ... Clearly, this stuff is all "processor specific"...also, UNIX doesn't ... are "processor specific" and UNIX was designed with "portability" in ...
    (alt.lang.asm)
  • Re: Big integer newbie problem
    ... asking Unix questions in a C newsgroup. ... to know a fair amount about C and a reasonable number of ... unsigned long long int physmem; ...
    (comp.lang.c)
  • Re: c++ comp. argument passing and prefix operator
    ... > Unix env.In fact the on Unix i got the correct. ... > void fn(int, int); ... Your personal expectations do not count, ... of the subexpressions of a full expression; ...
    (microsoft.public.vc.language)
  • istream read not reading everything
    ... I'm having trouble using istream to read in a file in its entirety on ... through a unix pipe to the program everything works ... int isready ... int timecount = 0; ...
    (comp.lang.cpp)
  • Problems with compilation
    ... under both Windows & UNIX. ... gc.c: In function `int main': ... gc.c:81: warning: assignment to `clock_t' from `double' ...
    (comp.programming)