作者:
bjk (Up2u)
2016-04-24 18:33:20請問在一個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.