Vertex
유형의 배열을 만든 다음 함수에서 각 멤버를 초기화하려고합니다. 함수에 내가 이것을 시도,"constructor"을 호출하는 일치 함수가 없습니다
class Application
{
//...
private:
Vertex data[3];
//...
};
및 소스 파일 : 나는이 같은 배열을 선언
Vertex::Vertex(const Vector3f& position) : position(position) { }
헤더 파일에서 다음 Vertex
클래스는 생성자에 Vector3f 소요
data[0] = Vertex(Vector3f(0, 0, 0));
data[1] = Vertex(Vector3f(0, 0, 0));
data[2] = Vertex(Vector3f(0, 0, 0));
하지만 컴파일 할 때이 오류가 얻을 :
/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() { }
^
를
배열을 정점 포인터로 선언하고 나서 data = new Vertex[3];
을 시도했지만 그 결과는 동일했습니다. 이 문제를 해결하려면 어떻게해야합니까?
Vertex에는 이와 같은 배열 내부에 기본 생성자가 필요합니다. –
인수가없는 생성자를 의미합니까? –
예 또는 기존 매개 변수가있는 기존 생성자. –