Tyler Seymour
Tyler Seymour

Reputation: 617

conversion of int to custom struct c++

I am trying to create a new object of type pointT from a Vector<int> coords. This is where my tutorial has led me, but I get the error that it cannot convert an int to a object pointT. setWall expects (a,b, bool) where a and b are of type pointT.

If this is not the way, how do I build xy from my vector?

Thanks

pointT xy =
{
    coords[0],
    coords[1]
};

m.setWall(xy.col, xy.col, false);}

Upvotes: 0

Views: 103

Answers (1)

erenon
erenon

Reputation: 19118

Try this:

struct point_t {
    int x;
    int y;
    point_t(const Vector<int>& v)
        :x(v.x),
         y(v.y)
    {}
};

point_t a(vecA);
point_t b(vecB);

m.setWall(a, b, false);

Upvotes: 2

Related Questions