关于c++的构造函数问题

https://stackoverflow.com/questions/62767072/questions-about-the-c-constructors?noredirect=1#comment110996743_62767072       

 1 #include <bits/stdc++.h>
 2 #include <sys/time.h>
 3 #include <time.h>
 4 using namespace std;
 5 
 6class test 
 7 {
 8 public:
 9   explicit test() 
10   {
11     printf("This is test's construct
");
12   }
13   ~test() 
14   {
15     printf("This is test's destroy
");
16   }
17 };
18    
19 int main()
20 {
21   test t();
22   return 0;
23 }                                                                

当我们去调用test t()的时候,编译器中 test t()被翻译成调用了一个函数叫做t(),然后返回一个test对象

并不会调用t的构造函数和析构函数

原文地址:https://www.cnblogs.com/letlifestop/p/13259357.html