( Tested on Linux/Cent OS 6.2 64 bit )

 

Let's say we have main function below....

 

int main(){
 First *fp = new First[10];          // creating array of First object
 delete [] fp;
return 0;
}

 

{If we have one of First classes below }// ??bytes of heap memory allocated


case 1:
class First{ double db; }// 8bytes * 10
class First{ int size;  }// 4bytes * 10
class First{ int *pt;  }// 8bytes * 10

 

case 2:
class First{ int size;
  int *pt;  }// 16 bytes * 10


class First{ int *pt;
  int size;  }// 16 bytes * 10

 

class First{ int size;
  double db; }// 16 bytes * 10


class First{ double db;
  int size;  }// 16 bytes * 10

 

case 3: 
class First{ int size;
  int size2;
  double db; }// 16 bytes * 10



 



 

class First{ double db;
  int size;
  int size2; }// 16 bytes * 10

 

 

 

class First{ int size;  
  double db;
  int size2; }// 24 bytes * 10

 

 

 

case 4:
class First{ int size;
  double db;
  int size2;
  char ch1; }// 24 bytes * 10

 





class First{ int size;
  double db;
  int size2;
  char ch1;
  char ch2;
  char ch3;
  char ch4; }// 24 bytes * 10

 





class First{ int size;
  double db;
  int size2;
  char ch1;
  char ch2;
  char ch3;
  char ch4; 
  char ch5; }// 32 bytes * 10