class G
{
public:
G() { puts("G"); }
G(const G& g) { puts("copy"); }
}
int main()
{
G A();
G B(A);
}
Compiling the code above with g++ -std=c++11
will cause error: no matching function for call to ‘G::G(G (&)())’
.
But if I replace the code G A();
with G A;
,everything is ok.
Can anyone tell me why ? And what's the difference between G A();
and G A;