-3
需求是创建一个流,将其传递给第二个函数进行修改(它必须以这种方式传递,因为输出需要访问私有数据成员单独的课程)。然后输出修改后的流。它按原样编译,但只返回MyStream的地址,我需要它返回流。试图通过ostream来运行和cout结果流ostream
/* Prints the details of the media collection. */
void MediaCollection::PrintMediaDetails() const{
ostream MyStream(NULL);
for(int i = 0; i < CurrentMCSize; i++){
TheCollection[i]->PrintMedia(MyStream);
cout << i + 1 <<" : "<<&MyStream;
}
}
/*Takes Stream and and returns data members*/
void Media::PrintMedia(ostream & Out) const{
Out<<Title<<" "<<Artist<<" "<<&RunningTime<<endl;
}
是否有问题打印的内容? – 0x499602D2
有什么问题?它工作吗?它是如何工作的?我们不是预测者。 – zoska
我想很清楚,特尼克想干什么。 他需要一个'std :: ostringstream',放入'PrintMedia'方法中的一些东西,然后输出'MyStream.str()'。 –