C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

no matching function to c'tor.

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Gary Wessle
Guest





PostPosted: Fri Nov 24, 2006 10:10 am    Post subject: no matching function to c'tor. Reply with 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();
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





PostPosted: Fri Nov 24, 2006 10:10 am    Post subject: Re: no matching function to c'tor. Reply with quote



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.

Quote:
A a(tt);

And here the compiler realizes that there is no way to construct an A object
from a function void->Test.

Quote:

}
[snip]



Best

Kai-Uwe Bux
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.