Hello guys,
I have the following problem
in my class vector i have this function:
vector<T> plus(vector<T>&);
which is initialized as followed:
template <class T>
vector::vector<T> plus(vector<T>& vec){
vector<T> result;
result.x=this.x+vec.x;
result.y=this.y+vec.y;
result.z=this.z+vec.z;
return result;
}
when i call two parameters type class vector a and be
when i do this :
a.plus(b); i get the following :
1>main.obj : error LNK2019: unresolved external symbol "public: class vector<int> __thiscall vector<int>::plus(class vector<int> &)" (?plus@?$vector@H@@QAE?
Your function definition is in the global scope, it needs to be in the scope of the class it is being defined for and you should probably pass by const reference:
yah you are right but vector class is the only one i have now , but anyways i tried that but didnt change the error:
1>main.obj : error LNK2019: unresolved external symbol "public: class vector<int> __thiscall vector<int>::plus(class vector<int> &)" (?plus@?$vector@H@@QAE?
I think theres a problem with passing class to a function is this is how it should be or am i doing something wrong
if i make my plus function like this for example;
template <class T>
vector<T>::plus(const vector<T>& vec)
{
vector<T> result;
result.x=vec.x;
result.y=vec.y;
result.z=vec.z;
return result;
}
and call plus(a) it works , i really dont know