我有這樣的:錯誤LNK1169:找到一個或多個多重定義的符號 - 全局函數
a.h
:
class a
{
}
void func(){} //some golobal function
b.h
:
include "a.h"
class b : public a
{
}
b.cpp
:
#include "b.h"
我得到的錯誤:
error LNK1169: one or more multiply defined symbols found
我覺得我得到的錯誤,因爲全局函數定義了兩次。我試圖把extern
之前的功能,但是沒有工作。我也使用#ifndef..
,我仍然得到錯誤。如何解決這個問題?
編譯器列出了被多次定義的符號。那些符號是什麼? – doptimusprime
如果'func'的定義在b.cpp文件中包含兩次,編譯器在編譯文件時會給出錯誤。 – doptimusprime
可能重複[應該使用前向聲明而不是包含任何可能的內容?](http://stackoverflow.com/questions/9906402/should-one-use-forward-declarations-instead-of-includes-wherever-possible) –