返回指向模板类的对象的双指针

Returning a double pointer to an object of template class

本文关键字:对象 指针 返回      更新时间:2023-10-16

我有一个模板类:

template<class T> 
class CVariable
{
     //lines ommited
};

和另一类:

class CLengthUnits:public CUnits
{
     //lines ommited
};

但当我试图从一个函数返回时:

CVariable<CLengthUnits>** PointsOfSection(void)
{
     //lines ommited
}

编译器给我一个错误:

error C2143: syntax error : missing ';' before '<'

有人知道吗?

template<class T> 
class CVariable**
{
   //lines ommited
};

星号不属于那里。拆下它们。


EDIT:作为对OP评论的回应,以下程序对我来说编译得很好:

class CUnits {};
template<class T>
class CVariable
{
     //lines ommited
};
class CLengthUnits:public CUnits
{
     //lines ommited
};
CVariable<CLengthUnits>** PointsOfSection(void)
{
     //lines ommited
}

我认为有些事情你还没有告诉我们。