error: no matching function for call to ''

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
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.
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.
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.)
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. :(
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.
hmm, i did that and i get this error now

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

@_@
Well that solved one problem. Is merge a member of your list class?
ahh no it wasn't. that fixed my problem. thanks guys!
Topic archived. No new replies allowed.