预测以下程序的输出。
null
#include<iostream> #include<stdlib.h> using namespace std; class Test { public : Test() { cout << "Constructor called" ; } }; int main() { Test *t = (Test *) malloc ( sizeof (Test)); return 0; } |
(A) 构造函数调用 (B) 空的 (C) 编译错误 (D) 运行时错误 答复: (B) 说明: 与new不同,malloc()不调用构造函数(参见 这 )
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END