0

I can't seem to get the implementation of my member list correct. I want to DEFAULT initialize my Set members nyX and nyY, however I keep getting an error.

class Location
{
public:

    vector<int> nyXv = { 0, 1, 2, 3, 4, 5};
    vector<int> nyYv = { 0, 1, 2, 3, 4, 5 };

    Set nyX(vector<int>);
    Set nyY(vector<int>);

    Location();
    ~Location();

    };


    Location::Location()
        :nyX(nyXv), nyY(nyYv)
    {
    }
user3666197
  • 1
  • 6
  • 50
  • 92
monkey doodle
  • 690
  • 5
  • 12
  • 22

1 Answers1

0

Look at this example

You can initialize you vectors like this:

class Location
{
    public:

    vector<int> nyXv;// = { 0, 1, 2, 3, 4, 5};
    vector<int> nyYv;// = { 0, 1, 2, 3, 4, 5 };

    ///...

    Location();
    ~Location();

};


static const int arrX[] = {0, 1, 2, 3, 4, 5};
static const int arrY[] = {0, 1, 2, 3, 4, 5};
Location::Location()
   :nyXv(arrX, arrX + sizeof(arrX) / sizeof(arrX[0]) )
   ,nyYv(arrY, arrY + sizeof(arrY) / sizeof(arrY[0]))
{
}

P.S. Of course there are many ways to improve this code but it should give you an idea

Community
  • 1
  • 1
mvidelgauz
  • 2,176
  • 1
  • 16
  • 23