2012-04-16 13 views
0

iはstuctureを持っている主な機能には、私が操作することができますオブジェクトを持つ構造体...例えば、setObj()関数を使用していますが、ControllerまたはController.hで関数を定義しようとするとら休閑エラー:タイプ定義の問題

..\ListStruc.cpp:28:28: error: 'Array' is not a type 
..\ListStruc.cpp: In function 'void add(int, int, int)': 
..\ListStruc.cpp:31:4: error: request for member 'M' in 'A', which is of non-class type 'int' 

EDIT:

void add(int cant, int tip,Array A){ 
//Adds to current day the amount to a specific type 

A.M[currentDay]; // i try to use this object. 
} 
+2

エラーは 'ListStruc.cpp'にあるようですので、おそらく関連コードを表示するべきです。 –

+0

addet、見てください –

+0

あなたの編集で 'add'の定義が宣言と一致しません。 –

答えて

2

この宣言が正しくありません:Arrayはクラステンプレートであるため

void add(int,int,Array &); 

add関数もテンプレートである必要があります:

template <class T> 
void add(int,int,Array<T> &); 

さらに、add関数の定義では、パラメータは値で、宣言ではパラメータを参照します。

+0

ありがとうございます。私はtempaltesで新しいテンプレート –

+1

あるいはテンプレートの特殊化を行っています: 'void add(int、int、Array &);' –