Write a program in c++ to overload >> operator using friend function.
#include <iostream>
class Point
{
private:
double m_x{};
double m_y{};
double m_z{};
public:
Point(double x=0.0, double y=0.0, double z=0.0)
: m_x{x}, m_y{y}, m_z{z}
{
}
friend std::istream& operator>> (std::istream &in, Point &point);
};
std::istream& operator>> (std::istream &in, Point &point)
{
in >> point.m_x;
in >> point.m_y;
in >> point.m_z;
return in;
}
Comments
Leave a comment