Search This Blog

Monday, 12 November 2012

An example for overloading insertion and extraction operators

#include<iostream.h>
class mark{
int m;
public:
friend istream & operator>>(istream &, mark &);
friend ostream & operator<<(ostream &, mark &);
};
istream & operator>>(istream &, mark &)
{
cout<<"Get Number";
cin>>m;
}
ostream & operator<<(ostream &,mark &)
{
cout<<"Given number="<<m;
}
void main()
{
mark k;
cin>>k;
cout<<k;
}


No comments:

Post a Comment