[問題] declaration of function in a function
請問在一個function裡面的declaration of function
是甚麼作用呢
謝謝
http://www.geeksforgeeks.org/output-of-c-program-set-5/
Question 3
#include<iostream>
using namespace std;
class Test
{
public:
Test();
};
Test::Test() {
cout<<"Constructor Called \n";
}
int main()
{
cout<<"Start \n";
Test t1();
cout<<"End \n";
return 0;
}
Run on IDE
Output:
Start
End
Note that the line “Test t1();” is not a constructor call. Compiler
considers this line as declaration of function t1 that doesn’t recieve any
parameter and returns object of type Test.
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.160.169.150
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1461494003.A.390.html
→
04/24 19:23, , 1F
04/24 19:23, 1F
→
04/24 20:09, , 2F
04/24 20:09, 2F
→
04/26 10:17, , 3F
04/26 10:17, 3F
推
04/26 23:29, , 4F
04/26 23:29, 4F
→
04/26 23:30, , 5F
04/26 23:30, 5F
→
04/28 18:50, , 6F
04/28 18:50, 6F