C++ 用于打印的返回点,已使用固有时间 原来这个问题解决了,在评论中是后来发生的问题;

C++ 用于打印的返回点,已使用固有时间 原来这个问题解决了,在评论中是后来发生的问题;,c++,pointers,printing,constants,operator-keyword,C++,Pointers,Printing,Constants,Operator Keyword,如何使Layer::printInfo()使用GeoObject::printInfo()打印信息 关于结构:标记是从类GeoObject继承的。GeoObject中包含文件Point.h。类点中存储的信息是int long和int lat(坐标点的纬度) 现在,我正试图通过覆盖虚拟方法printInfo(从GeoObject继承)来打印存储在类标记对象中的信息。问题出在这一行: strPrint将ostream作为参数 void Print(ostream &out) 更改此行:

如何使Layer::printInfo()使用GeoObject::printInfo()打印信息

关于结构:标记是从类GeoObject继承的。GeoObject中包含文件Point.h。类点中存储的信息是int long和int lat(坐标点的纬度)

现在,我正试图通过覆盖虚拟方法printInfo(从GeoObject继承)来打印存储在类标记对象中的信息。问题出在这一行:
str
Print
ostream
作为参数

void Print(ostream &out)
更改此行:

str << GeoObject::getDesc() << ": " << GeoObject::getPoint().Print() << ", " << size << ", "<< colour ;

str
Print()。指向GeoObject类的不同对象的指针(Inherrite类是Marker和Polygon)存储在list myLayer中。在方法Layer::printInfo()中调用方法GeoObject::printInfo(),以打印该层的所有数据。使用下面的代码(见下一条注释)。在输出中,我看到调用了Layer::printInfo(),但没有打印任何信息。为什么?如何打印这些信息?void Layer::printInfo()const{//为每个存储的地理对象使用为其编写的printInfo方法。for(list::const_iterator it=myLayer.begin();it!=myLayer.end();it++){cout printInfo();//printInfo返回字符串}非常感谢。这就成功了,解决了其他错误
void Print(ostream &out)
        {
            out << longt <<", "<<lat ;
        }
void Print(ostream &out)
str << GeoObject::getDesc() << ": " << GeoObject::getPoint().Print() << ", " << size << ", "<< colour ;
str << GeoObject::getDesc() << ": ";
GeoObject::getPoint().Print(str);
str << ", " << size << ", "<< colour ;