c++ - Return variable as a Class Object -
i have created string class using character array.
i need place array instead of class object. here's easy example.
i want print a integer , not b class object isn't possible.
#include <iostream> class t { int ; public : t ( ) { = 10 ; } } ; void main ( ) { t b ; std :: cout << b ; } is possible?
okay, how?
you need output stream operator:
std::ostream& operator <<(std::ostream& o, const t& t) { return o << t.a; } note that, since a private, have friend of t.
Comments
Post a Comment