3
我想使用模板在图像中创建区域的排序列表。这里定义的类在相同的文件中有更多的实现。C++模板中的模板对象
template <typename RegionType>
class SortedType
{
public:
SortedType();
~SortedType();
void makeEmpty();
bool isFull() const;
int lengthIs() const;
void retrieveItem(RegionType&, bool&);
void insertItem(RegionType );
void deleteItem(RegionType );
void resetList();
bool isLastItem() const;
void getNextItem(RegionType&);
private:
int length;
NodeType<RegionType> *listData;
NodeType<RegionType> *currentPos;
};
节点的结构定义是:
template <typename DataType>
struct NodeType
{
DataType info;
NodeType<DataType> *next;
};
当我尝试编译代码,我得到的错误:错误:SortedType不上,我原型的功能,使用线式SortedType类。我认为它与我用于SortedType类的模板有关,NodeType类导致某种问题,但我不知道如何解决它。
编辑 出现的第一个错误上是试制的功能:
int computeComponents(ImageType &, ImageType &, SortedType &);
我在使用该SortedType类的所有函数原型错误。 NodeType在SortedType之前声明。
显示在您的原型使用SortedType类的函数线;或错误的行对应于 – 2012-04-03 00:59:32
看起来很好提供NodeType SortedType之前声明 – Anycorn 2012-04-03 01:04:23