Ok so I applied the scoping operator. Here is the new code and errors.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
node * studentList::find(int id)
{
node * finder = head;
while(finder != NULL)
{
if(finder -> data.id == id)
{
return finder;
}
else
{
finder = finder -> next;
}
}
return finder;
}
|
Errors:
error C2143: syntax error : missing ';' before '*'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2556: 'int *studentList::find(int)' : overloaded function differs only by return type from 'studentList::node studentList::find(int)'
1> studentList.cpp(57) : see declaration of 'studentList::find'
error C2040: 'studentList::find' : 'int *(int)' differs in levels of indirection from 'studentList::node (int)'
When I change code
node * finder = this -> head
.
New code and errors.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
node * studentList::find(int id)
{
node * finder = this head;
while(finder != NULL)
{
if(finder -> data.id == id)
{
return finder;
}
else
{
finder = finder -> next;
}
}
return finder;
}
|
Errors:
error C2143: syntax error : missing ';' before '*'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2556: 'int *studentList::find(int)' : overloaded function differs only by return type from 'studentList::node *studentList::find(int)'
see declaration of 'studentList::find'
error C2371: 'studentList::find' : redefinition; different basic types
see declaration of 'studentList::find'
error C2440: 'initializing' : cannot convert from 'studentList *const ' to 'studentList::node *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
error C2146: syntax error : missing ';' before identifier 'head'