I have a struct like so defined like so:
But when I try to define a global array of the structs all the values are lost and instead it is treated as if I didn't give it any values.
I define the array like this:
However if I create a Vector3 outside of an array everything remains intact.
Code:
//vector3.h
struct Vector3
{
float x, y, z;
Vector3();
Vector3(float _x, float _y, float _z);
Vector3(const Vector3 &v);
};
//vector3.cpp
#include "vector3.h"
Vector3::Vector3()
{
x = y = z = 0.0f;
}
Vector3::Vector3(float _x, float _y, float _z)
{
x = _x;
y = _y;
z = _z;
}
Vector3::Vector3(const Vector3 &v)
{
x = v.x;
y = v.y;
z = v.z;
}
I define the array like this:
Code:
const Vector3 octagon[] = { Vector3(-0.5f, -1.5f, 0.0f),
Vector3(0.5f, -1.5f, 0.0f),
Vector3(-1.5f, -0.5f, 0.0f),
Vector3(-1.5f, 0.5f, 0.0f),
Vector3(-0.5f, 1.5f, 0.0f),
Vector3(0.5f, 1.5f, 0.0f),
Vector3(1.5f, 0.5f, 0.0f),
Vector3(1.5f, -0.5f, 0.0f),
Vector3(0.5f, -1.5f, 0.0f),
Vector3(-0.5f, 0.5f, 0.0f),
Vector3(-0.5f, -0.5f, 0.0f),
Vector3(-1.5f, -0.5f, 0.0f) };
Comment