M
Metro12
Beyond my expectations, the result of the following program is 1
not 8. I want to know how the complier allocates memory for such a
class, and why the class Test's size does not contain the struct
TestNode's.
#include <iostream>
using namespace std;
class Test
{
public:
Test(){}
~Test() {}
private:
struct TestNode
{
int num;
char ch;
};
char ch1;
};
int main(void)
{
//the output is 1, not 8.Why?
cout << "size of Test: " << sizeof(Test) << endl;
return 0;
}
Thanks!
not 8. I want to know how the complier allocates memory for such a
class, and why the class Test's size does not contain the struct
TestNode's.
#include <iostream>
using namespace std;
class Test
{
public:
Test(){}
~Test() {}
private:
struct TestNode
{
int num;
char ch;
};
char ch1;
};
int main(void)
{
//the output is 1, not 8.Why?
cout << "size of Test: " << sizeof(Test) << endl;
return 0;
}
Thanks!