我遇到模板類專業化問題,請參閱下面的代碼。C++,模板專業化問題
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;
}
謝謝,我在與您發佈答案的同時糾正了我的代碼:-) – Johnas 2011-05-06 21:02:18