【发布时间】:2011-05-06 20:47:43
【问题描述】:
我在模板类专业化方面遇到问题,请参阅下面的代码。
template <typename T>
class Point
{
private
T x, y;
typedef T Type;
public:
Point ( const T & x_, const T & y_) : x ( x_ ), y ( y_ ) {}
};
template <typename Item>
struct TItems
{
typedef std::vector <Item> Type;
};
template <typename Item>
class Container
{
protected:
typename TItems <Item>::Type items;
public:
typedef Item type;
};
是否可以为 Point 专门化 Container 类?
更新问题:
我试过下面的代码,有效吗?
template <typename T>
class Container < Point <T> >
{
};
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
Container <Point <double> > points;
}
【问题讨论】:
标签: c++ templates specialization