-1
我不确定这个问题是否与我的IDE一样,但我尝试了Code :: Blocks和Visual Studio两个项目,所以我不认为它是。对“Class :: method”C++的未定义引用?
我的主文件:
#include <iostream>
#include "Hello.h"
using namespace std;
int main()
{
Hello firstMan;
firstMan.greeting();
firstMan.goodbye();
firstMan.goodbye();
}
我Hello.h:
#ifndef HELLO_H_INCLUDED
#define HELLO_H_INCLUDED
class Hello
{
public:
void greeting();
void goodbye();
};
#endif // HELLO_H_INCLUDED
我的类文件Hi.cpp:
#include <iostream>
#include "Hello.h"
using namespace std;
void Hello::greeting()
{
cout << "Hello" << endl;
}
void Hello::goodbye()
{
cout << "Bye" << endl;
}
我刚开始C++,所以我很抱歉,如果这是一个简单的错误或只是一个错字。