这是我的代码和声明,我不确定如何使用模板类正确设置朋友功能。有人可以指导我做错什么,为什么吗?
谢谢!
private:
int size;
T* buff;
friend Vector<T> operator * (const int n, const Vector<T> & v);
friend Vector<T> operator + (const int n, const Vector<T> & v);
template<typename T>
Vector<T> operator * (const int n, const Vector<T> & v){
Vector<T> vec(v.size);
vec.size = v.size;
for(int i = 0;i<vec.size;i++){
vec.buff[i] = v.buff[i]*n;
}
}
template<typename T>
Vector<T> operator+ (const int n, const Vector<T> & v){
Vector<T> vec(v.size);
vec.size = v.size;
for(int i = 0;i<vec.size;i++){
vec.buff[i] = v.buff[i]*n;
}
}