개발자
template<typename E > class Node { public: Node() : next(nullptr), prev(nullptr) {} bool operator<(Node N) { return N.data < data; } bool operator>(Node N) { return N.data > data; } template<typename E> friend ostream& operator<<(ostream& os, const Node<E>& N) { os << N.data; return os; } private: E data; Node<E>* next; Node<E>* prev; friend class LinkedList<E>; }; 다른print 함수{cout<<Node객체.data} 이렇게 E타입의 data를 <<로 출력해야 하는데 [ C2679 이항 '<<': 오른쪽 피연산자로 'const E' 형식을 사용하는 연산자가 없거나 허용되는 변환이 없습니다. ] 자꾸 위와 같은 오류가 뜹니다... 그래서 template<typename E>를 연산자 오버로딩 앞에 붙여봐도 [ C2995 'std::ostream &operator <<(std::ostream &,const Node<E> &)': 함수 템플릿이 이미 정의되었습니다. ] 이런 오류가 발생하구요. 템플릿 타입을 <<로 어떻게 출력하나요??
답변 0
첫 답변을 기다리고 있어요.
지금 가입하면 모든 질문의 답변을 볼 수 있어요!
현직자들의 명쾌한 답변을 얻을 수 있어요.
이미 회원이신가요?
지금 가입하면 모든 질문의 답변을 볼 수 있어요!