( 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
'๐ป Programming' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
์๋๋ก์ด๋ ํฐ์ ์น์ฌ์ดํธ ๋ฐ๋ก๊ฐ๊ธฐ ๋ง๋ค๊ธฐ (0) | 2019.03.03 |
---|---|
[C++] pipe() and fork() (ํ์ดํ, ํฌํฌ) (0) | 2019.02.15 |
[MyBatis] ์ ๋ฌ๋ฐ์ ๊ฐ์ฒด์ ๊ฐ ์ธํ ํ๊ธฐ (selectKey) (0) | 2018.02.03 |
[Git] ํ๊ทธ ์ญ์ ํ๊ธฐ (removing git tag) (0) | 2018.01.24 |
[ Node.js in Action ] 13์ฅ ์์ฝ (0) | 2017.06.03 |