C++

Started by
26 comments, last by Shannon Barber 19 years, 7 months ago
Do you ever provide a definition (not just a declaration) for the CSnake constructors?
Advertisement
I was missing a CSnake(); body, but now it shows 5 unresolved links :/ I"ll check it now. but the missing body CSnake constructor body is a good reason
;)
In the CSnake class change this:

CSnake();

to this:

CSnake(void);

This makes a difference in some compilers.
i have added the void, all the files are compiled well, but when i make a build, it gives me 5 linker errors

these errors are from CSnake's "sub" files , like a linked list and all the rest. But it worked, the thing is the snake worked.
I just wanted to imigrate it into win 32 API :/ :\
Shall i upload the whole code?

WinSnake error LNK2019: unresolved external symbol "public: __thiscall MCPoint::MCPoint(int,int)" (??0MCPoint@@QAE@HH@Z) referenced in function "public: __thiscall CSnake::CSnake(int,int)" (??0CSnake@@QAE@HH@Z)

WinSnake error LNK2019: unresolved external symbol "public: __thiscall CList::CList(void)" (??0CList@@QAE@XZ) referenced in function "public: __thiscall CSnake::CSnake(int,int)" (??0CSnake@@QAE@HH@Z)

WinSnake error LNK2019: unresolved external symbol "public: void __thiscall CList::pushHead(class CNode *)" (?pushHead@CList@@QAEXPAVCNode@@@Z) referenced in function "public: void __thiscall CSnake::setSnake(class MCPoint)" (?setSnake@CSnake@@QAEXVMCPoint@@@Z)

WinSnake error LNK2019: unresolved external symbol "public: __thiscall CNode::CNode(class MCPoint)" (??0CNode@@QAE@VMCPoint@@@Z) referenced in function "public: void __thiscall CSnake::setSnake(class MCPoint)" (?setSnake@CSnake@@QAEXVMCPoint@@@Z)

WinSnake error LNK2019: unresolved external symbol "public: class CNode * __thiscall CList::popBack(void)" (?popBack@CList@@QAEPAVCNode@@XZ) referenced in function "private: void __thiscall CSnake::flip(void)" (?flip@CSnake@@AAEXXZ)

WinSnake fatal error LNK1120: 5 unresolved externals
;)
>:
;)
Have you implemented funcion bodies for MCPoint::MCPoint(int,int), CList::CList(void), etc. ?
Sometimes when I get linker errors I have to delete the .obj files in the debug folder.
This doesn't always work, but sometimes it does.
____________________________________________________________Programmers Resource Central
Here is the whole directory

http://www.geocities.com/sinner_val/winsnake/ws.zip

I give up on programing :( I"m going to study agriculture and build a farm or something...
;)
Quote:Original post by Anonymous Poster
In the CSnake class change this:

CSnake();

to this:

CSnake(void);

This makes a difference in some compilers.

Not in C++ compilers. In C, a function declared to take no parameters (void) is different from one without parameter declarations; in C++ this is not the case.
Where is your snake.cpp file?

The code that I downloaded does not have the implementation of CSnake.

The linker errors are valid.

- Alek

This topic is closed to new replies.

Advertisement