I have a problem with pattern and pointers (I think). The following is part of my code:
#ifndef ITEMCOLLECTION_H #define ITEMCOLLECTION_H #include <cstddef> using namespace std; template <class T> class ItemCollection { public: // constructor //destructor void insertItem( const T ); private: struct Item { T price; Item* left; Item* right; }; Item* root; Item* insert( T, Item* ); }; #endif
And the file with the defintion function:
#include <iostream> #include <cstddef> #include "ItemCollection.h" template <class T> Item* ItemCollection <T>::insert( T p, Item* ptr) { // function body }
Here are the errors that are generated by this line of code:
Item* ItemCollection <T>::insert( T p, Item* ptr)
Errors:
error C2143: syntax error: missing ';' before '*'
error C4430: missing type specifier - int. Note: C ++ does not support default-int
error C2065: "Type": undeclared identifier
error C2065: "Type": undeclared identifier
error C2146: syntax error: missing ')' before identifier 'p'
error C4430: missing type specifier - int. Note: C ++ does not support default-int
error C2470: "ItemCollection :: insert": looks like a function definition, but there is no list of parameters; skipping the visible body
error C2072: 'ItemCollection :: insert': function initialization
error C2059: syntax error: ')'
Any help is greatly appreciated.