我有在衍生clases前的operatorr <<
一个问题:运营商<<在派生类C++
如果我有
class Base
{
//......
friend ostream& operator<<(ostream& out,Base &B)
{
return out<<B.x<<B.y<</*........*/<<endl;
}
//......
};
是如下因素更多钞票?
class Derived: public Base
{
//......
friend ostream& operator<<(ostream& out,Derived &DERIVEDOBJECT)
{
return out<<DERIVEDOBJECT<<DERIVEDOBJECT.nonderivedvar1 <</*.....*/<< endl;
}
}
或把DERIVEDOBJECT
在<<
运营商将不会导致<<
recoqnizing它只是在基类的引用?
@Aleksander - 使用每个代码语句前4位或只使用'{}'这是本作的editior窗口代码格式。 – Mahesh 2011-04-20 21:56:23