mercredi 21 janvier 2015

Structures and Arrays (too many initializers for ‘Array’ ) C++

Why I get error :too many initializers for ‘Array’ Its C++11 code and I dont know where is problem



#include <iostream>
using namespace std;

struct Point {
int x,y ;
};
Point points[3] {{1,2},{3,4},{5,6}};
int x2 = points[2].x;

struct Array {
Point elem[3];
};

int main() {
cout << "!!!\nStructure!!!" << endl; //

Array points2 {{1,2},{3,4},{5,6}};// *too many initializers for‘Array’*
int y2 = points2.elem[2].y;

cout << "!!!here points2 = !!!" << y2 <<endl;

return 0;
}

Aucun commentaire:

Enregistrer un commentaire