내 < < 연산자가 올바르게 호출되지 않는 경우 약간의 문제가 있습니다.가상 << operator
class SomeInterface
{
friend std::ostream& operator<<(std::ostream& str, const SomeInterface& data);
protected:
virtual void print(ostream& str) const = 0;
};
inline std::ostream& operator<< (std::ostream& o, SomeInterface const& b)
{
b.print(o);
return o;
}
}
호출하는 코드는 다음과 같은 : :
SomeInterface* one = new someConcrete();
cout << one;
I 인터페이스에 전화를받을 바라고 된 < < 오버로드 기능이 아닌, 커녕 파견
이
내가 가진 무엇 통해 파생 클래스.
감사합니다 ... 나는 그것이 같은 주소를 인쇄 한 후에 짐작한다 찌꺼기. –