c++ - Template class and class properties that are also templates -


I'm having trouble compiling the following headers, this is my first experience with templates and I think that something wrong Compiler point errors are being done by vector & lt; Vector & lt; T & gt; & Gt; Data _; and operator overloading function. I want to keep the data_ vector as the OptBaseMatrix object but I'm not sure how to do this ... I do not really know how to solve this problem Turned out help!

  #ifndef OPTBASEMATRIX_H #defineOPTBASEMATRIX_H #include & lt; Vector & gt; Template & lt; Typename T & gt; Class Optbase Matrix {Public: Vector & lt; Vector & lt; T & gt; & Gt; Information_; Opt-in matrix (int rows, int colals); ~ OptBaseMatrix (); Read Zero Matrix (); Zero print matrix (); Int getRows (); Int getCols (); OptBaseMatrix & LT; T & gt; Operator + (Constant Optus Matrix & lt; T & gt; and Matrix 1, Constant Metabolism & lt; T & gt; and Matrix 2); Private: INTER Rows_; Int cols_; }; #endif // OPTBASEMATRIX_H  

UPDATE : Here is a snippet from the debugger log:

  Error 1 error C2143: Syntax error : missing ';' '& Lt;' Before Optbasematrix.h 17 TD2 error 2 error C4430: Missing type specifier - int assumed. Note: C ++ does not support the default-int optbasematrix.h 17 TD2  

I have tried to modify the vector> data_; Vector> Data_by; And still get the same error: / I read somewhere that my template class header (.h) and implementation (.cpp) should be in the same file ... is it possibly related?

Update 2 : Wow! I forgot "using the namespace std"; The problem is fixed now!

Give you two & gt; / Code>.

  vector & lt; Vector & lt; T & gt; & Gt; Information_;  

Without space, & gt; & Gt; is considered as a stream extraction / right-shift operator.

In addition, you either need to declare the code as a free code or you must declare it with only one parameter:

  // member job matrix & lt; T & gt; Operator + (Const Metrix & lt; T & gt; and others) const; // Free Function ('Friend' frees the function even if it has been declared in the scope of class definition) Buddy Matrix & lt; T & gt; Operator + (Const Metrix & lt; T & gt; & amp; LHS, Const Metrix & lt; T & gt; & amp; amp; rhs);  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -