could not convert {...} from <brace-enclosed initializer list> to struct
The problem is here:
struct Test
{
int x = 0; // <==
Vector2 v;
};
Until recently, default member initializer prevent the class from being an aggregate, so you cannot use aggregate initialization on them. Gcc 4.9 still implements the old rules here, whereas gcc 5 uses the new ones.
You missed ;
after your class definition and after int x = 0
. Then you got many errors and apparently only considered the last one. But your compiler was confused because Vector2
was not defined (due to missing ;
).
This compiles:
int main()
{
class Vector2
{
public:
Vector2(float x, float y)
{
this->x = x;
this->y = y;
}
float x = 0.f;
float y = 0.f;
};
struct Test
{
int x;
Vector2 v;
};
Test tst = {0,Vector2(4,5)};
return 0;
}