我有以下代码: 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