[try Beta version]
Not logged in

 
error: no matching function for call to ''

Apr 10, 2010 at 8:10pm
Hello, i am new to this forum and trying to create a merge sort function.

Upon testing, i get this error.

" error: no matching function for call to 'merge(List&, List&)' "


when i try to call it in the main, this is how it looks

1
2
3
4
List list1;
List list2;
...(bunch of code that fills both lists above with values)...
List merged_list = merge( list1, list2); 


in my list.h file, it looks like this

List& merge( const List* one, const List* two );

and here is the list.cpp

1
2
3
4
5
List& merge( const List* one, const List* two )
{
...(bunch of code for merge sorting)....
return *newList;
}



what am i doing wrong? thanks!
Last edited on Apr 10, 2010 at 8:11pm
Apr 10, 2010 at 8:24pm
I'm not sure if it will actually change anything because I never pass by pointer, but there is no call for REFERENCE parameter, not pointer. Try changing those pointers in your arg list to references and see what happens.
Apr 10, 2010 at 8:33pm
the same thing happened :(.

I want to write it in a way so that the function has two parameters, that both point to two seperate lists, and i want it to return a pointer to the new merged list.
Apr 10, 2010 at 8:35pm
Hm. Maybe it's a problem with the includes. I hate to ask such a simple question but did you link the merge implementation with your main source code? (I gotta be missing something simple but for the life of me I can't think of it.)
Apr 10, 2010 at 8:38pm
no i did not.

my merge implementation is in my list.cpp. and in my main, i used iostream and list.h as my include. All function calls to other functions in the list.cpp work except this one. :(
Apr 10, 2010 at 9:22pm
You aren't passing the addresses of the List objects list1 and list2. Use &list1 and &list2 when calling the function and see if that works.
Apr 10, 2010 at 9:56pm
hmm, i did that and i get this error now

" undefined reference to 'List::merge(List const*, List,const*)' "

@_@
Apr 10, 2010 at 9:59pm
Well that solved one problem. Is merge a member of your list class?
Apr 10, 2010 at 10:08pm
ahh no it wasn't. that fixed my problem. thanks guys!
Topic archived. No new replies allowed.