C++ C++;未定义的引用

C++ C++;未定义的引用,c++,reference,undefined,C++,Reference,Undefined,我有很多未定义的引用。我不知道我做错了什么 我得到以下错误: undefined reference to 'LetteroidField::start()' undefined reference to 'LetteroidField::setTitle(std::string)' undefined reference to 'Letteroid::setletter(char)' undefined reference to 'Letteroid::setLetter()' undefin

我有很多未定义的引用。我不知道我做错了什么

我得到以下错误:

undefined reference to 'LetteroidField::start()'
undefined reference to 'LetteroidField::setTitle(std::string)'
undefined reference to 'Letteroid::setletter(char)'
undefined reference to 'Letteroid::setLetter()'
undefined reference to 'Letteroid::setCoords()'
undefined reference to 'Letteroid::erase()'
和其他字母参考

我还没有完成其他的课程,但我不知道为什么会出现这些错误。我是否正确使用了#include“”

这是我教授的示例代码。我联系了他,但他没有回答(这是一个在线课程)


#包括“letteroidfield.h”
#包括“letteroid.h”
#包括“blinkingletteroid.h”
#包括“jumpingletteroid.h”
#包括“movingletteroid.h”
#包括/*srand,兰特*/
#包括
///在此处包含派生类
int main()
{
莱特菲尔德屏幕;
screen.start();
screen.setTitle(“Ken的示例,按“x”退出该类”);
闪烁的字母型;
闪烁字母2;
闪烁字母三;
一个.setLetter(“!”);///字符
一.setCoords(5,10);///行,列
两个字母(“h”);
2.setCoords(7,9);
三、固定字母('@');
3.赛特库德(15,57);
跳跃字母四;
四、固定字母(“j”);
四.setCoords(rand()%21,rand()%21);
活动字母5;
五、固定字母(“m”);
int x=20;
int y=20;
而(x>=1)
{
--x;
}
而(y>=1)
{
--y;
}
如果(x==1)
{
x=20;
}
如果(y==1)
{
x=20;
}
五、赛特库德(x,y);
///在此处创建并初始化您的字母ID
while(screen.waitForKeyPress())///继续,直到按下“x”
{
一、眨眼;
二、眨眼;
三、眨眼;
///在此处调用绘制字母ID的函数
}
screen.end();
返回0;
}

\ifndef\u LETTEROIDFIELD\u H_
#定义_LETTEROIDFIELD_H_
#包括
类文本字段
{
公众:
void start();///启动字体ID的屏幕
bool waitForKeyPress();///等待按下任何键(返回
void end();///关闭屏幕并将其返回到
void setTitle(std::string);///d显示标题
};
#恩迪夫
#如果没有_
#定义字母_
类字母
{
公众:
void setCoords(int,int);//设置位置(向下,横向)
void setLetter(char);//设置字符
int getX();//放下位置
int getY();//获取位置
void erase();//从屏幕上删除字母ID
void draw();//将字母ID绘制到屏幕上
私人:
int-myX;
int-myY;
碳聚酯薄膜;
};
#恩迪夫


您需要问自己的问题是:这些类在哪里定义

如果答案是:“在标题旁边提供的共享库(文件扩展名“.so”)中”,则需要通过向编译命令中至少添加以下内容来链接该库:

g++ main.cpp -L</path/to/library> -l<library_name>
 g++ main.cpp <library_name.a>
g++ main.cpp <source_file1.cpp> <source_file2.cpp> ...
g++main.cpp-L-L
如果答案是:“在标题旁边提供的静态库(文件扩展名“.a”,又称归档文件)中”,那么您需要将其包含在二进制文件中,方法是在编译命令中至少添加以下内容:

g++ main.cpp -L</path/to/library> -l<library_name>
 g++ main.cpp <library_name.a>
g++ main.cpp <source_file1.cpp> <source_file2.cpp> ...
g++main.cpp
如果答案是:“在标题旁边提供的一组源文件中”,那么您需要将它们包括在二进制文件中,方法是向编译命令中至少添加以下内容:

g++ main.cpp -L</path/to/library> -l<library_name>
 g++ main.cpp <library_name.a>
g++ main.cpp <source_file1.cpp> <source_file2.cpp> ...
g++main.cpp。。。
您能显示您的LETTEROID类的.cpp的包含(或整个类)吗?我认为问题在于,您没有包含类的标题