Page 1 of 2

Snekgame unresolved externals

Posted: March 26th, 2017, 11:02 am
by misterchi
Why these bugs?

10k you

Re: Snekgame unresolved externals

Posted: March 26th, 2017, 11:33 am
by Zedtho
I'll check this later, but what do you mean with "10k you"?

Re: Snekgame unresolved externals

Posted: March 26th, 2017, 12:14 pm
by misterchi
read it fast :D

Re: Snekgame unresolved externals

Posted: March 26th, 2017, 1:01 pm
by chili

Code: Select all

Snake.obj : error LNK2019: unresolved external symbol "public: __cdecl Snake::Segment::Segment(void)" (??0Segment@Snake@@QEAA@XZ) referenced in function "public: __cdecl Snake::Snake(struct Location const &)" (??0Snake@@QEAA@AEBULocation@@@Z)
1>Snake.obj : error LNK2019: unresolved external symbol "public: void __cdecl Snake::Segment::InitHead(struct Location const &)" (?InitHead@Segment@Snake@@QEAAXAEBULocation@@@Z) referenced in function "public: __cdecl Snake::Snake(struct Location const &)" (??0Snake@@QEAA@AEBULocation@@@Z)
1>Snake.obj : error LNK2019: unresolved external symbol "public: void __cdecl Snake::Segment::Follow(class Snake::Segment const &)" (?Follow@Segment@Snake@@QEAAXAEBV12@@Z) referenced in function "public: void __cdecl Snake::MoveBy(struct Location const &)" (?MoveBy@Snake@@QEAAXAEBULocation@@@Z)
1>Snake.obj : error LNK2019: unresolved external symbol "public: void __cdecl Snake::Segment::Draw(class Board &)" (?Draw@Segment@Snake@@QEAAXAEAVBoard@@@Z) referenced in function "public: void __cdecl Snake::Draw(class Board &)" (?Draw@Snake@@QEAAXAEAVBoard@@@Z)
You don't have any implementations for any of these functions. That's what the errors say.

Re: Snekgame unresolved externals

Posted: March 26th, 2017, 1:28 pm
by misterchi
Ok.

Do you know why Visual Studio underlines the brace in the picture I added?

misterchi

Re: Snekgame unresolved externals

Posted: March 26th, 2017, 1:39 pm
by chili
If you put your cursor on the underlined part it will tell you.

My guess is you have some embedded object with no default constructor and it cannot instantiate it.

Re: Snekgame unresolved externals

Posted: March 27th, 2017, 5:32 pm
by misterchi
Hi,

it says: the default constructor of "Snake::Segment" cannot be referenced-- it is a deleted function

What should I do? I programmed the same like you did in the Tutorial 14a.

Re: Snekgame unresolved externals

Posted: March 27th, 2017, 7:09 pm
by albinopapa
Do you have a line in class Snake::Segment like
Snake::Segment() = default;

Re: Snekgame unresolved externals

Posted: March 28th, 2017, 3:19 pm
by misterchi
No, I don't have that line. But when I add a constructor the red underline disappears. The odd thing is that I did it like Chili did and his program works.

Re: Snekgame unresolved externals

Posted: March 28th, 2017, 3:37 pm
by chili
I can 100% guarantee that you didn't do it like me :D

If you wanna know what you missed, post your full code (the non working stuff) and I'll take a look at it.