Hi,
Now we will discuss the operator < <> > overloading. One of the advantages of using the iostream objects is that we can customize it to support our own classes.
We will just remeber few things while overloading the these operaor
Points.
1)An overloaded < <>
using namespace std;
class Base
{
public:
int a;
Base()
{
a = 100;
}
friend ostream& operator <<(ostream &os,const Base &obj);
};
ostream& operator << (ostream& os, Base & bb) {
os << bb.a;
os << '/';
return os;
}
int main()
{
Base bb1;
cout << bb1 << endl;
}
Monday, October 8, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment