вообщем проблема, есть шаблон в нем обьявлен оператор
| Код | template <class Type> class Matrix { ....................
friend Matrix<Type> operator+<>(const Type Variable,const Matrix<Type> SecObj); ........... };
|
определение
| Код | Matrix<Type> operator+(Type Variable, Matrix<Type> SecObj) { Matrix<Type> Temp(SecObj.GetRows(), SecObj.GetColumns()); for(int i = 0; i < SecObj.GetRows(); i++) for(int j = 0; j < SecObj.GetColumns(); j++) *(*(Temp.pMatrix) + i + j) += Variable return Temp; }
|
ошибки| Код | d:\Programming\Open Projects\Matrix\Matrix.h(34) : error C2143: syntax error : missing ';' before '<' d:\Programming\Open Projects\Matrix\Matrix.h(38) : see reference to class template instantiation 'Matrix<Type>' being compiled d:\Programming\Open Projects\Matrix\Matrix.h(34) : error C2460: 'operator`+'' : uses 'Matrix<Type>', which is being defined d:\Programming\Open Projects\Matrix\Matrix.h(34) : error C2433: 'operator`+'' : 'friend' not permitted on data declarations d:\Programming\Open Projects\Matrix\Matrix.h(34) : error C2238: unexpected token(s) preceding ';' d:\Programming\Open Projects\Matrix\Matrix.h(277) : error C2904: '+' : name already used for a template in the current scope d:\Programming\Open Projects\Matrix\Matrix.h(34) : see declaration of 'operator`+'' d:\Programming\Open Projects\Matrix\Matrix.h(34) : error C2143: syntax error : missing ';' before '<' d:\Programming\Open Projects\Matrix\Main.cpp(6) : see reference to class template instantiation 'Matrix<Type>' being compiled with [ Type=int ] d:\Programming\Open Projects\Matrix\Matrix.h(34) : error C2460: 'operator`+'' : uses 'Matrix<Type>', which is being defined with [ Type=int ] d:\Programming\Open Projects\Matrix\Matrix.h(34) : error C2433: 'operator`+'' : 'friend' not permitted on data declarations d:\Programming\Open Projects\Matrix\Matrix.h(34) : error C2238: unexpected token(s) preceding ';' d:\Programming\Open Projects\Matrix\Main.cpp(21) : error C2677: binary '+' : no global operator found which takes type 'Matrix<Type>' (or there is no acceptable conversion) with [ Type=int ]
|
при другом обьявлении
| Код | template <class Type> class Matrix { ....................
friend Matrix<Type> operator+(const Type Variable,const Matrix<Type> SecObj); ........... };
|
ошибки Main.obj : error LNK2019: unresolved external symbol "class Matrix<int> __cdecl operator+(int,class Matrix<int>)" (??H@YA?AV?$Matrix@H@@HV0@@Z) referenced in function _main Debug/Matrix.exe : fatal error LNK1120: 1 unresolved externals
IDE VS2003, подскажите в чем ошибка и есть ли она вооще или это compiler bag |