mercredi 24 juillet 2019

How to initialize a value to a object decleared in a vector?

Well, my question is how can I set a value to the object cood of class coordinates created in a vector.

#include <iostream>
#include <vector>

using namespace std;

class coordinates
{
public:
    short int x;
    short int y;
};

int main()
{
    vector<coordinates> cood[1];
    cood[1].x=(short int)4;
    cood[1].y=(short int)5;

    return 0;
}

I am getting this error

class std::vector' has no member named 'y' for both x and y.

I have tried different methods but always get some error.

THANK YOU for help.

Aucun commentaire:

Enregistrer un commentaire