C++;错误';对Class::Function()的未定义引用 我只是想知道有没有人能帮我解决这个问题,我是C++新手,当我把课程分成不同的文件时,我遇到了一个问题。

C++;错误';对Class::Function()的未定义引用 我只是想知道有没有人能帮我解决这个问题,我是C++新手,当我把课程分成不同的文件时,我遇到了一个问题。,c++,oop,undefined,header-files,undefined-reference,C++,Oop,Undefined,Header Files,Undefined Reference,编译SepMain.cpp文件时出现的错误是: /usr/bin/ld: /tmp/cciHobHn.o: in function `main': SepMain.cpp:(.text+0x23): undefined reference to `Sep::Sep()' collect2: error: ld returned 1 exit status /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu

编译SepMain.cpp文件时出现的错误是:

/usr/bin/ld: /tmp/cciHobHn.o: in function `main':
SepMain.cpp:(.text+0x23): undefined reference to `Sep::Sep()'
collect2: error: ld returned 1 exit status
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
collect2: error: ld returned 1 exit status
编译Sep.cpp文件时出现的错误是:

/usr/bin/ld: /tmp/cciHobHn.o: in function `main':
SepMain.cpp:(.text+0x23): undefined reference to `Sep::Sep()'
collect2: error: ld returned 1 exit status
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
collect2: error: ld returned 1 exit status
编译Sep.h文件时出现的错误是:

bash: /home/ishan/Coding/C++/Learn/tempCodeRunnerFile: Permission denied
所以我的代码有三个文件:

九月

#include "Sep.h"        
#include <iostream>

using namespace std;   
Sep::Sep()
{
    cout<<"hello"<<endl;
}
SepMain.cpp

#include "Sep.h"
#include <iostream>

using namespace std;

int main()
{
    Sep ir;
    return 0;
}
#包括“Sep.h”
#包括
使用名称空间std;
int main()
{
Sep-ir;
返回0;
}

>不执行.CPP或.h文件,而是将C++文件编译成可执行文件并执行。然后-当然-SepMain.cpp不知道构造函数定义,Sep.cpp没有main函数。您必须编译这两个文件并将它们链接在一起以形成实际的应用程序。您的编译器应该能够that@IWonderWhatThisAPIDoes你能告诉我如何编译这两个文件并将它们链接在一起形成一个实际的应用程序吗?不幸的是,这些东西都依赖于编译器。你用的是什么编译器?@Iwonderhatthisapido编译器是gcc版本9.3.0,我在ubuntu中使用它