Function Call *Help*

I cant not figure out whats the problem with my function call. I keep getting these errors.
1
2
3
4
5
prog5.cpp: In function `int main()':
prog5.cpp:48: error: no matching function for call to `IntList::selectionSort(int&)'
IntList.h:25: note: candidates are: void IntList::selectionSort()
IntList.cpp:55: error: prototype for `void IntList::selectionSort(IntList::ListNode*)' does not match any in class `IntList'
IntList.h:25: error: candidate is: void IntList::selectionSort()


my .h file
1
2
3
4
5
6
7
8
9
     6  private:
     7      
     8      struct ListNode

    14  public:
    15      

    25      void selectionSort(  ); 
    26 };


in my main prog this is where i call it.
1
2
3
4
     9      IntList myList;
     10

     48     myList.selectionSort( n );


in my .cpp file where the function is located at
1
2
3
4
    53
    54  void IntList::selectionSort(ListNode *nodePtr)
    55  {
    56


You declared it as void variables and you are trying to pass it variable n. You have it set up as a function with a variable in the description but void in your declaration. Line 25 is your error, the parenthesis should not be empty.
you should declare void selectionSort(ListNode*) or void selectionSort(int*)
in you .h file i think.
also since it seems at first glance that ListNode* is not an int*,then you should declare both functions
in your class.
Last edited on
when i use void selectionSort(ListNode*);
only these errors occur
1
2
prog5.cpp:48: error: invalid conversion from `int' to `IntList::ListNode*'
prog5.cpp:48: error:   initializing argument 1 of `void IntList::selectionSort(IntList::ListNode*)' 
cut my error down to 1. Cant seem to get my way around it.
error
1
2
prog5.cpp: In function `int main()':
prog5.cpp:48: error: invalid type argument of `unary *'


my line in the .h file
26 void selectionSort(ListNode * nodePtr);

my new function call
48 myList.selectionSort( *n );
48 myList.selectionSort(*n) doesn't mean anything,you should pass a pointer to a node,
try 48 myList.selectionSort(&n) if n is a node.if n is a pointer to a node just pass n to the function.
n is just an int that i declared to pass integers from a function to another. I have other functions that i use n but this is the only one i need to use node pointers in.
Last edited on
Since the function takes a ListNode*, you need to pass it one. You can't pass an int and expect it to work.
got ya.

what does this error represent prog5.cpp:48: error: expected primary-expression before ')' token
Probably since n is an int, *n has no meaning so the compiler is confused.
Topic archived. No new replies allowed.