Template objects in templates in C ++

I am trying to create a sorted list of regions in an image using templates. The class defined here has its implementation further down 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;
}; 

      

Definition of a node structure:

template <typename DataType>
struct NodeType
{
   DataType info;
   NodeType<DataType> *next;
};

      

when I try to compile the code, I get the error: error: SortedType is not a type in the string where I prototype the 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 problem, but I'm not sure how to fix it.

edit The prototyped function with which the first error appears is the following:

int computeComponents(ImageType &, ImageType &, SortedType &);

      

I have errors in all function prototypes that use the SortedType class. NodeType is declared before SortedType.

+3


source to share


1 answer


int computeComponents(ImageType &, ImageType &, SortedType &);

      

it should be



template <typename RegionType>
int computeComponents(ImageType &, ImageType &, SortedType< RegionType > &);

      

+2


source







All Articles