以下两种创建对象的方法有什么区别?对象创建差异
Test* t = new Test();
和
Test* t;
你的回答第二个样本匹配什么,我认为这会做(没有创建对象),但
class Test {
public:
void bla(void) {
std::cout << "test" << std::endl;
};
};
int main(void) {
Test* test;
test->bla();
}
给我输出的“测试”。 ..所以,实际上有一个对象
我修复了你的格式。第一次编辑的免费;-) – Johnsyweb 2011-06-08 11:41:58
你确定你不是指第二个片段中的'Test t'? – 2011-06-08 11:49:31
你的意思是创建一个对象和不创建对象之间的区别? – 2011-06-08 12:16:47