2015-04-18 37 views
0

我試圖在C++中創建對象數組,但我得到了一些奇怪的錯誤,我不知道爲什麼。一些錯誤,當我嘗試創建obejct數組

Complex ** tab; //class field 

matrix::matrix(int x, int y) //construktor 
{ 
    tab = new Complex * [x]; 
    for (int i = 0; i < x; i ++) 
    { 
     tab[i] = new Complex[y]; 
    } 

的錯誤是:

1> matrix.obj:錯誤LNK2019:解析外部符號 「公共:__thiscall複雜::絡合物(無效)」(?? 0Complex @@ @ QAE XZ)引用在公共函數「public:__thiscall矩陣::矩陣(int,int)」(?? 0矩陣@@ QAE @ HH @ Z)

1> matrix.obj:error LNK2019:無法解析的外部符號「public:__thiscall Complex: :函數「public:__thiscall matrix :: matrix(int,int)」中引用的「〜Complex(void)」(?? 1Complex @@ QAE @ XZ)

有什麼不對?

+1

[見這個問題](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-修復),也許[這個答案](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-doi-i-fix/12574407 #12574407)或[this one](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix/12574400 #12574400)。 – chris

+0

某種奇怪的評論。 –

回答

0

當你的程序編譯並未能鏈接以默認的構造函數和析構函數的默認,很明顯,你缺少實施

Complex::Complex() 
Complex::~Complex() 

提供的實現,它應該解決您的問題。他們應該是微不足道的,你錯過了包括雙打開緊密支撐?

Complex { 
    ...... 
    Complex(){} 
    ~Complex() {} 
    ........ 

} 
+0

我再次重寫並開始工作; d thx。 我可以再問一個問題嗎?這是我第一次在stackoverflow上。你能告訴我,爲什麼當我問幾秒鐘後我得到很多「 - 」並報告?難道我做錯了什麼? – Hangoverflow

相關問題