我正在尝试使用模板创建一个按区域排序的图像列表。此处定义的类在同一文件中的其余部分中有其实现。
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类的函数所在的行上,出现错误:error: SortedType不是一种类型。我认为这与我正在使用的SortedType类和NodeType类的模板有关,导致某种问题,但我不确定如何解决它。
编辑:第一个错误出现的原型化函数是:
int computeComponents(ImageType &, ImageType &, SortedType &);
我使用SortedType类的所有函数原型中都出现了错误。NodeType在SortedType之前被声明。