Hello, i have a small problem. i have to classes and one acts like the head node, while other acts as the list, consists of some data and another pointer to the next list.
#include "EmployeeNode.h"
class EmployeeList {
private:
EmployeeNode* head;
public:
EmployeeList();
EmployeeNode* locateEmployee( int emplNum );
bool locateEmployee( int emplNum, char*& firstName, char*& lastName ); // if emplNum does not exists return FALSE; TRUE otherwise
} ;
EmployeeList::EmployeeList()
{
}
bool EmployeeList::locateEmployee( int emplNum, char*& firstName, char*& lastName )
{
EmployeeNode * lct=head;
while (lct != NULL)
{
if(lct->getEmplNumber() == emplNum)
{
return (true);
}
lct =lct->getNext(); //This is valid to do right?, i am telling it
//to go to the object and evoke the getNext() on it.
}
}
i am not so sure why am i getting a error, lct = lct->getNext() should be fine.
thank you in advance
Error::
EmployeeList.o:EmployeeList.cpp|| undefined reference to `EmployeeNode::getEmplNumber()'|
\EmployeeList.o:EmployeeList.cpp|| undefined reference to `EmployeeNode::getNext()'|
\mingw\lib\libmingw32.a(main.o):main.c|| undefined reference to `WinMain@16'|
||=== Build finished: 3 errors, 0 warnings ===|
i Think i can ignore the winmain@16 error for now cause i haven't made a make file.
i tried on the different function, i am doing similar thing, trying to locate a node, this should work, i said go to whats tpr is pointing to then evoke the accessor getnext(), which will fetch the next node. same for getEmplNumber() which will fetch the number.
a small update lets say, on purpose i make an error like put NUl, rather NULL, the compiler will only warn me that NUL is undefined the other error, like the undefined reference doesn't come up.
Okay -- your problem is you're not linking to whatever source file has those function bodies. You need to link to that cpp file. If you were using an IDE, you could just add the file to your project, but since you're compiling by hand you have to type some cryptic stuff into the command prompt which I can't help you with.
the compiler will only warn me that NUL is undefined the other error, like the undefined reference doesn't come up.
That's because the errors you're getting are linker errors. The linker isn't run until all compiling is complete, and if there are any compiler errors, then the linker doesn't run at all (so you don't get any linker errors).
As for the WinMain error -- WinMain is the entry point for Win32 programs (instead of the usual 'main'). So you have an incorrect setting somewhere. You'll need to fix this too.
... maybe you are using an IDE? How are you building this program?