Try the following:
Code:
#include <iostream>
using namespace std;
class Line; // Forward Declaration for friend
class Point
{
friend ostream& operator<< ( ostream& , const Line&);
friend istream& operator>> ( istream& , Line&);
private:
int x,y;
};
class Line : public Point
{
friend ostream& operator<< ( ostream& , const Line&);
friend istream& operator>> ( istream& , Line&);
private:
int color;
public :
void draw () { cout<< "Drawing a Line" << endl; }
};
inline
ostream& operator<< ( ostream &os , const Line &out )
{
os << "Line: [" << out.x << "," << out.y << " ," << out.color << " ]" << endl;
return os;
}
inline
istream& operator>> ( istream &is , Line &in )
{
cout << "Line x , y , color info: " << endl;
is >> in.x >> in.y >> in.color;
return is;
}
int
main(int argc, char *argv)
{
Line new_line;
cin >> new_line;
cout << new_line;
return(0);
}