Reputation: 396
I am trying to create a sorted list of regions in an image using templates. The class defined here has its implementation further down in the same file.
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;
};
The node struct definition is:
template <typename DataType>
struct NodeType
{
DataType info;
NodeType<DataType> *next;
};
when I attempt to compile the code, I get the error: error: SortedType is not a type on the line where I prototype a function to use the SortedType class. I think it has something to do with the templates I am using for the SortedType class and the NodeType class is causing some sort of problem, but I'm not sure how to fix it.
edit The prototyped function that the first error appears on is:
int computeComponents(ImageType &, ImageType &, SortedType &);
I have errors in all function prototypes that use the SortedType class. NodeType is declared before SortedType.
Upvotes: 3
Views: 127
Reputation: 51485
int computeComponents(ImageType &, ImageType &, SortedType &);
should be
template <typename RegionType>
int computeComponents(ImageType &, ImageType &, SortedType< RegionType > &);
Upvotes: 2