似乎无法使错误消失。错误如下。我已经看过Google了,但仍然想不起来。并不是我不是Cpp的新手,但有一段时间没有被它弄糊涂了。

奇怪的是它与Windows中的G ++一起使用...

错误:

[ze @ fed0r!- - - ** _ _ *] $ G ++的main.cpp

/tmp/ccJL2ZHE.o:在函数“ main”中:

main.cpp :(。text + 0x11):对`Help :: Help()的未定义引用

main.cpp :(。text + 0x1d):对'Help :: sayName()'的未定义引用

main.cpp :(。text + 0x2e):对`Help ::〜Help()'的未定义引用

main.cpp :(。text + 0x46):未定义对`Help ::〜Help()'的引用

collect2:ld返回1退出状态

main.cpp

#include

#include "Help.h"

using namespace std;

int main () {

Help h;

h.sayName();

// ***

// ***

// ***

return 0;

}

帮助

#ifndef HELP_H

#define HELP_H

class Help {

public:

Help();

~Help();

void sayName();

protected:

private:

};

#endif // HELP_H

帮助文件

#include

#include "Help.h"

using namespace std;

Help::Help() { // Constructor

}

Help::~Help() { // Destructor

}

void Help::sayName() {

cout << "            ***************" << endl;

cout << "   ************************************" << endl;

cout << "              ************" << endl;

cout << "         *********************" << endl;

}

标签c ++ g ++

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐