I am trying to create an array of type Vertex
and then initialize each member in a function. The Vertex
class takes a Vector3f in the constructor:
Vertex::Vertex(const Vector3f& position) : position(position) { }
In the header file I declare the array like this:
class Application
{
//...
private:
Vertex data[3];
//...
};
and in the source file, in a function I try this:
data[0] = Vertex(Vector3f(0, 0, 0));
data[1] = Vertex(Vector3f(0, 0, 0));
data[2] = Vertex(Vector3f(0, 0, 0));
But when I try to compile I get this error:
/home/mert/dev/C++/C++3D/src/Application.h: In constructor ‘Application::Application()’:
/home/mert/dev/C++/C++3D/src/Application.h:31:19: error: no matching function for call to ‘Vertex::Vertex()’
Application() { }
^
I have tried declaring the array as a Vertex pointer and then doing data = new Vertex[3];
but the result was the same. What should I do to fix this?