Right that's the code written to experiment with custom stream inserters; the problem I have with the above code is that MSVC++ 6.0 on WinXP gives me errors whereas gcc doesn't on Linux redhat 8. The errors regard accessing the private members in the class from the definnition of the inserter. Any takers on why this is so??Code:#inlcude <iostream> #include <cstring> using namepsace std; class tst{ char name[15]; int acode, pNum; public: tst(char *nm, int areacode, int num) {name = nm; acode=areacode; pNum=num;} friend ostream &operator<<(ostream &stream, tst obj); } ostream &operator<<(ostream &stream, tst obj); { stream<< "NAME: "<< obj.name <<".\nNUMBER: "; stream<< obj.acode <<'-'<<obj.pNum<<".\n\n"; return stream; } int main() { tst a("Lan", 44208, 6946360); cout<<a<<endl; //<< also MSVC finds this line ambiguos return 0; }



LinkBack URL
About LinkBacks



. Also thanx. I have SP5 on disk just forgot to install it.