 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Gary Wessle Guest
|
Posted: Fri Nov 24, 2006 10:10 am Post subject: no matching function to c'tor. |
|
|
Hi
the errors below the code here is my problem. I don't understand
why. can you please help.
thanks
class Test
{
public:
Test(){}
};
class A
{
Test t;
public:
A(Test x):t(x){}
};
int main(){
Test tt();
A a(tt);
}
****************************************************************
cd /home/fred/myProg/toy/
make -k
g++ -gdwarf-2 -c -o main.o main.cpp
main.cpp: In function ‘int main()’:
main.cpp:16: error: no matching function for call to ‘A::A(Test (&)())’
main.cpp:11: note: candidates are: A::A(Test)
main.cpp:8: note: A::A(const A&)
make: *** [main.o] Error 1
make: Target `proj' not remade because of errors.
Compilation exited abnormally with code 2 at Fri Nov 24 16:16:10 |
|
| Back to top |
|
 |
Kai-Uwe Bux Guest
|
Posted: Fri Nov 24, 2006 10:10 am Post subject: Re: no matching function to c'tor. |
|
|
Gary Wessle wrote:
| Quote: |
Hi
the errors below the code here is my problem. I don't understand
why. can you please help.
thanks
class Test
{
public:
Test(){}
};
class A
{
Test t;
public:
A(Test x):t(x){}
};
int main(){
Test tt();
|
The line above does not declare a variable of type Test but a Test-valued
function without arguments. (This really should be a FAQ, but I didn't find
it.) The rule of thumb is: if it can be parsed as a function declaration,
then it is.
And here the compiler realizes that there is no way to construct an A object
from a function void->Test.
Best
Kai-Uwe Bux |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|