0
std::ostream& operator<<(std::ostream&, const Course&);
void Course::display() {
std::cout << std::left << courseCode_ << " | " << std::setw(20) << courseTitle_ << " | " << std::right
<< std::setw(6) << credits_ << " | " << std::setw(4) << studyLoad_ << " | ";
}
std::ostream& operator<<(std::ostream& os, const Course& a) {
a.display();
return os;
}
a.display()
이하의 ostream 연산자를 구현할 때 문제가 발생합니다. 문제가있는 곳이 보이지 않습니다. 동일한 구현으로 작동하는 다른 코드가 있습니다.개체에 멤버 함수와 호환되지 않는 형식 한정자가 있습니다. C++
오류 메시지 :
목적은 멤버 함수 "SICT :: 과정 :: 디스플레이"개체 형식과 호환되지 않는 한정자를 입력있다가 const를 SICT이다 :: 코스
가능 중복 [링크] (http://stackoverflow.com/questions/24677032/object-has-type-qualifiers-that-are-not-compatible-with-the-member-function) –
'Course :: display' 함수는 왜'std :: cout'에 쓰기 위해 하드 코드되어 있습니까? 파일에 쓰기를 원한다면 (이것은'operator <<'오버로드로 가능할 것입니다)? –