(1) 下面的union在内存是怎么安排的?gcc和vc编译的时候,分配的内存size是一样的吗?
typedef union
{
char m:3;
char n:7;
int data;
}value;
(2) 下面地址一致吗?
char value1[] = {"hello"};
char value2[] = {"hello"};
char* pValue1 = “hello”;
char* pValue2 = "hello";
value1和value2地址一致吗?pValue1和pValue2呢?
(3)下面一段话为什么运行错误?为什么内存泄露了?怎么修改?
class apple
{
char* pName;
public:
apple() { pName = (char*)malloc(10);}
~apple() {if(NULL != pName) free(pName);}
};
void process()
{
apple a, b;
a = b;
}
(全文完)