C++实例化对象时加()与不加()的区别
#include <iostream>
2 using namespace std;
3
4 class Test
5 {
6 public:
7 Test(){cout << "Test()" << endl;}
8 ~Test(){cout << "~Test()" << endl;}
9 Test(const Test &t){cout << "Test(const Test &t)" << endl;}
10 private:
11 int x;
12 int y;
13 };
14
15 int main()
16 {
17
18 Test t1;
19 Test t2();
20 return 0;
21 }
为什么实例化t2时不会执行构造函数?