Undefined reference to class constructor, including .cpp file fixes

前端 未结 6 1625
萌比男神i
萌比男神i 2020-12-24 14:14

The problem I am having is that, when I call a constructor for a class I have created I get the following error.

main.cpp:20: undefined reference to

6条回答
  •  暖寄归人
    2020-12-24 14:44

    including the cpp file causes the compiler to build that code as part of that file (which you should not do), what you need to do is compile the GameObject/StaticObject.cpp file as its own object, and link the 2 objects together.

提交回复
热议问题