Как правильно перегрузить оператор ввода?
В простом классе необходимо перегрузить оператор ввода. По непонятной, для меня, причине выдаёт ошибку :"Ошибка (активно) E0349 отсутствует оператор ">>", соответствующий этим операндам, типы операндов: std::istream >> Shape::Color" Помогите пожалуйста разобраться.
Shape.h
class Shape
{
public:
enum Color { Red, Black, Green, Blue };
protected:
Color color;
public:
virtual Shape* Make()const = 0;
virtual void Print();
Shape(Color color);// конструктор с одним параметром
Shape(const Shape& other);// конструктор крпирования
virtual~Shape();
void Set_Color(int x); // присваим значение
virtual int Get(); // принимаем значение
virtual int Square(); // площадь фигуры
void printMyShape(); // распичатываем
virtual Shape& operator = (const Shape& other);
virtual bool operator == (const Shape& other)const;
bool operator != (const Shape& other);
friend std::ostream& operator<<(std::ostream& os, const Shape& an);
friend std::istream& operator >>(std::istream& os, Shape& nov);
};
std::ostream & operator << (std::ostream & os, const Shape& an);
std::istream& operator >>(std::istream& os, Shape& nov);
Shape.cpp
#include"Shape.h"
void Shape::Print()
{
std::cout << this->color << std::endl;
}
Shape::Shape(Color color)
{
this->color = color;
}
Shape::Shape(const Shape& other)
{
color = other.color;
}
Shape::~Shape()
{
std::cout << "Now I am in Shape's destructor!" << std::endl;
}
void Shape::Set_Color(int x)
{
this->color = static_cast<Color>(x);
}
int Shape::Get()
{
return this->color;
}
int Shape::Square()
{
return 0;
}
void Shape::printMyShape()
{
std::cout << this->color << std::endl;
}
Shape& Shape::operator = (const Shape& other)
{
this->color = other.color;
return *this;
}
bool Shape::operator == (const Shape& other)const
{
return this->color == other.color;
}
bool Shape::operator!=(const Shape& other)
{
return !(this->color == other.color);
}
//bool Shape::operator==(const Shape* other)
//{
// if (typeid(*other) == typeid(Circle))
// {
// return static_cast<const Circle&>(*other)==*this;
// }
// else
// {
// return false;
// }
//}
std::ostream& operator<<(std::ostream& os, const Shape& an)
{
os << an.color;
return os;
}
std::istream& operator>>(std::istream& os, Shape& nov)
{
os >> nov.color;
return os;
}