开发者

C++ implement generic class

开发者 https://www.devze.com 2023-02-16 07:04 出处:网络
I am trying to create a generic class in C++ but I am getting the error \"expected constructor, destructor, or type conversion before \'<\' token \" on lines 6, 16, 19...

I am trying to create a generic class in C++ but I am getting the error "expected constructor, destructor, or type conversion before '<' token " on lines 6, 16, 19...

I am just creating a simple class and pretty sure I can go on from there. Here is the sample code I am dealing with:

using namespace std;

//line 6  
generic < class T>  
class Table  
{  
 friend class Table;  
        Table< T> *LT;  
        LT_Node* cursor;  

 public:  
        Table();    
        ~Table();  
        Table(const Table  & source);  
        Table& operator =(const Table& rhs);  
};

//line 16  
generic < class T>  
Table< T>::Table(){}

//line 19  
generic 开发者_StackOverflow< class T>  
Table< T>::~Table(){}

generic < class T>  
Table< T>::Table(const Table  & source){}

generic < class T>  
Table::Table& operator =(const Table& rhs){}

Thanks in advance!


If this is ordinary C++ the keyword isn't generic but template. You are defining a template for a class or function, that is later instantiated when used.

0

精彩评论

暂无评论...
验证码 换一张
取 消