我有以下代碼: file.h:C++/Ubuntu - 在模板錯誤
#ifndef __ANA_H__
#define __ANA_H__
template <class T>
class ana {
class ana1{//code
}*anna1;
public:
bool method(T& data,ana::ana1 &a);
};
#endif
file.cpp:
#include <ana.h>
#include <iostream>
using namespace std;
template <class T>
bool ana<T>::method(T& data,ana::ana1 &t) {
cout << "Data = " << data << endl;
if(data > 0) {
return true;
}
return false;
}
我有錯誤:ana::ana1 is not a type
。如何解決這個錯誤?我在哪裏錯了?需要一些help.thx 我在ubuntu工作,我編譯使用g ++的代碼。我從我發佈的.h和.cpp創建了一個.a。
的名字,像'__ANA_H__',其中包含下劃線,或以下劃線開始在用戶編寫的代碼是不允許的。將其更改爲'ANA_H' – 2011-05-10 09:57:29
@unapersson:包含下劃線很好;包含*兩個連續的*下劃線是問題(以及從一個當然開始)。 – ildjarn 2011-05-10 10:03:57
@ildjam確實 - 這就是我的意思,但顯然沒有打字。 – 2011-05-10 10:07:13