我在我的主目录中有一个未定义的引用错误。不知道我做错了什么,并尝试改变名称和移动的东西,但不断得到相同的错误。我想知道,如果,也许这是我的IDE,但真的不知道 下面的代码:未定义的文件引用
#include <iostream>
#include "f.h"
#include "g.h"
using namespace std;
int main()
{
F f;
G g;
f.f();
g.g();
return 0;
}
下一个文件:
#ifndef F_H_INCLUDED
#define F_H_INCLUDED
class F
{
public:
void f();
};
#endif
下一个文件:
#ifndef G_H_INCLUDED
#define G_H_INCLUDED
class G
{
public:
void g();
};
#endif
下一个文件:
#include "f.h"
#include <iostream>
void F::f()
{
std::cout << "This was function f!" << std::endl;
}
下一个文件:
#include "g.h"
#include <iostream>
void G::g()
{
std::cout << "This was function g!" << std::endl;
}
编辑:所以我改变了从“f.h”和“g.h”到“f.cpp”和“g.cpp”包括和现在的作品......任何人都可以解释,为什么?
确保您实际编译并链接了包含功能的3个文件 – 2015-04-02 02:29:46
什么是完整的错误信息? – teppic 2015-04-02 02:32:37
未定义的引用'F :: f()' – cppfan 2015-04-02 02:33:57