I am drawing shapes in an SVG file that I generate through input I give with a .dat file.
I need to take a line from the .dat file, and remove 4 individual integers from it, and save those integers into a vector. To do this, I've attempted to create a class, square, that holds 4 integers (they represent the top left and bottom right coordinates of the square). Preferably, I'd be able to do this in a constructor of the class, but I have no idea to go about doing that.
Essentially, I know I'll have a string that looks something like "1 1 50 50," and I want to turn it into 4 integers. The issue I'm having is that I need to make it 4 integers of a class object, not just 4 integers.
class SQ
{
public:
sq() = default;
static int tl_x;
static int tl_y; //top left corner
static int br_x;
static int br_y; //bottom right corner
};
I've tried the code below, but it obviously doesn't work because it only saves the first integer it comes across.
while (getline(file,s))
{
int *f = new int(stoi(s));
vec.push_back(f);
}
I appreciate any help :)