一 下面这段代码会不会出错,有没有问题
int n = 0;
BOOL  *p = new(BOOL[n]);
delete p;

What is a COM object? How is it represented in C++?

List the four types of casts in C++. What are the differences between them, and how are they used?

Is the following legal C++? Why or why not?
char *p = “Hello”;

解决方案 »

  1.   

    第一个问题很意思。第一个问题这样写VC不会报错,而且能得到一个非NULL值的地址。但是没有开辟空间。也就是说你不能给
    (*p)附值。不然会产生意想不到的结果,因为你不知道你修改的到底是谁占用的地址空间。而且你给(*P)
    附值后再delete p;程序会报错。第四个问题VC中认为是合法的。可以使用
      

  2.   

    1.delete [] p;
    2.COM 组件对象模型
    3.reinterept_cast,static_cast,dynamic_cast,const_cast
    4.char *p = “Hello”;//不能这样用,Hello存放在静态存储区
      

  3.   


    Is the following legal C++? Why or why not?
    char *p = “Hello”;In my opnion ,It's legal.
      

  4.   

    char *p = “Hello”;
    明显可以嘛,c/c++ 不是本来就是那么使用的吗?
    和 char p[]="Hello" 没什么区别吧。