이 오류 점점 :C++ 운영자 오류
C : \ CodeBlocks \ 쿨 \ praks3 \ vector.h | 62 | 오류 : 통과 'CONST 벡터 < 2U>'표준 '의'이 '인수로 : 문자열을 벡터 :: toString() [짧은 부호없는 int n = 2u] '한정자 삭제 | 이 코드
:
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
template <unsigned short n>
class Vector {
public:
std::vector<float> coords;
Vector();
Vector(std::vector<float> crds);
float distanceFrom(Vector<n> v);
std::string toString();
template <unsigned short m>
friend std::ostream& operator <<(std::ostream& out, const Vector<m>& v);
};
template <unsigned short n>
std::string Vector<n>::toString() {
std::ostringstream oss;
oss << "(";
for(int i = 0; i < n; i++) {
oss << coords[i];
if(i != n - 1) oss << ", ";
}
oss << ")";
return oss.str();
}
template <unsigned short m>
std::ostream& operator<<(std::ostream& out, const Vector<m>& v) {
out << v.toString(); // ERROR HEEEERE
return out;
}
축하합니다. 그래서, 당신의 질문은 무엇입니까? 나는 위의 하나의 물음표가 보이지 않습니다. – AnT