I'm unfamiliar with OO in C++.
I've been pushing instances of the MyPoint
class into
vector <MyPoint> trianglePoints;
like this:
trianglePoints.push_back(MyPoint(x,y));
This is my definition of MyPoint:
class MyPoint {
public:
float x;
float y;
MyPoint(float x, float y) //constructor
{
this->x=x;
this->y=y;
}
}; //end
After pushing three points into the vector I call a function to render the triangle and then do:
trianglePoints.clear();
Questions:
a) How do I get my three x,y coordinates from the vector? I want to store each into its own int xi,yi to render them.
b) Is it okay to call clear()
on the vector even though I haven't defined a destructor for the MyPoint class?