我想递归地使用模板来定义(在编译时)一个d元组的d元组。下面的代码在Visual Studio 2010中编译得很好,但是g ++失败了,并且抱怨说它“无法直接调用构造函数”point < 1> :: point'。递归模板:在g ++下的编译错误
任何人都可以请说一说这里发生了什么?
非常感谢,乔
#include <iostream>
#include <utility>
using namespace std;
template <const int N>
class point
{
private:
pair<double, point<N-1> > coordPointPair;
public:
point()
{
coordPointPair.first = 0;
coordPointPair.second.point<N-1>::point();
}
};
template<>
class point<1>
{
private:
double coord;
public:
point()
{
coord= 0;
}
};
int main()
{
point<5> myPoint;
return 0;
}
MAny谢谢 - 这澄清了我的困惑/误解。 – Johannes 2011-03-15 20:17:33