C++ error, Undefined reference class

后端 未结 1 1837
难免孤独
难免孤独 2021-01-29 04:17

Why does codeblocks give this error \"Undefined reference to class::classfunction()\" It happens when a class is created in a separated file.All of these files are in the same f

1条回答
  •  离开以前
    2021-01-29 05:00

    You need to link both main.o and class.o into your executable. The exact command depends on your compiler and OS. For g++ the command would look something like

    g++ -o main main.cpp class.cpp
    

    0 讨论(0)
提交回复
热议问题