When trying to attempt to overload operator<<
in my shape.cpp
, it can't seem to recognize the variables within the class, even though it is a friend
of the class.
My .cpp
file:
#include "Shape.h"
ostream& operator << (ostream& cout, const Shape& shapes)
{
for (int i = 0; i < points.size(); i++) //points is undefined
{
cout << points[i] << endl;
}
}
My .h
file:
#include <vector>
#include "Point.h"
#pragma once
using namespace std;
class Shape
{
friend ostream& operator << (ostream& cout, const Shape& shapes);
private:
vector <Point> points; //Ordered list of vertices
};
I already used the same overload for my point
class and it worked fine.