-
ostream& outrage !!!
Code:
const ostream& Diver:: list(ostream& out_tr) const
{
cout<<"I am the trouble";
cout<<id_;
cout<<"Or me";
out_tr<<name_<<" "<<country_<<" ";
cout<<"The hole is here";
out_tr<<tmp_avg_<<endl;
return out_tr;
}
>>> compilation passed
and then trouble
I use member.list(cout)
in main()
those lousy outputs are my attempt to find problem, but always failed after "I am the trouble"
or should it be like this?
Code:
const ostream& Diver:: list(ostream& out_tr) const
{
cout<<id_<<" "name_<<" "<<country_<<" "<<tmp_avg_<<endl;
return out_tr;
}
-
Are you certain that the stream represented by out_tr is open?
-
What problem?
I recommend writing debug output to cerr, or at least flushing cout after EACH output.
-
>>but always failed after "I am the trouble"
You mean, "I am the touble" didn't output correctly, or do you mean id_ didn't output correctly? If id_ failed, then chances are:
a) id_ is an unsigned char or pointer to a datatype other than char
b) or id_ is filled with some 'garbage' value
c) or the whole object is filled with some 'garbage' values, i.e. it wasn't initialized.