undefined reference to Base::object linker error @ c++ w/ freeglut

孤者浪人 提交于 2019-12-05 21:49:29
Alok Save

It is a Linker error, which tells you that the Linker cannot find definition for the static member Living::spriteImg, this is because you just declare it in your class but you never defined it.

You ned to define the static member in your Living.cpp:

Sprite* Living::spriteImg = NULL;

Remember that you need to define it in one and only one .cpp file.

Good Read:
What is the difference between a definition and a declaration?

Living::SpriteImg is a static data member. You have only declared it in the class Living.

However, static data members also needs to be defined separately, preferably in a .cpp file.

// .cpp file
Sprite* Living::spriteImg = 0;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!