我有一個標題,我聲明瞭一個函數。然後我創建該函數並嘗試使用它,但我得到一個錯誤。這是通過引用,但我不知道爲什麼它不工作。參考錯誤
struct.h
#ifndef LISTSTRUC_H_
#define LISTSTRUC_H_
template <class T> struct Array{
int days;
T * M;
Array(int size) : days(size), M(new T[size])
{
}
~Array()
{
delete[] M;
}
};
void currentDay();
template <class Expe>
void dummyData(Array<Expe> &);
#endif /* LISTSTRUC_H_ */
struct.cpp
void dummyData(Array <Expe> &A){
for(int i=0; i<31; i++){
A.M[i].Expe::setObj((i*3),(i*1),(i*6),(i*2),(i*4),(i*5));
}
}
M.cpp(主CPP)
int main(){
//Main function of the program. no pre/ post condition.
Array <Expe> A(31); // Work space
Array <Expe> B(31); // Backup space
dummyData(&A); // error
}
ERROR:
..\M.cpp:22:14: error: no matching function for call to 'dummyData(Array<Expe>*)'
改變dummyData (一個); D:\ C++ \ Begin \ Lab3-5_OOP \ Debug /../ M.cpp:22:未定義引用'void dummyData(Array &)' –
2012-04-18 16:12:46
您有'#include'd文件嗎'dummyData '被宣佈? – 2012-04-18 16:15:43
在M.cpp中我有includet #include「Expe.h」 #include「ListStruc.h」 – 2012-04-18 16:19:05