2013-10-04 6 views
1

armadillo 행렬 인스턴스에서 malloc을 호출하는 규칙은 무엇입니까?armadillo 객체의 malloc

100x100 매트릭스에 메모리를 미리 할당하려면이 방법이 적합합니까?

fmat* squareMat = (fmat*)malloc(sizeof(fmat(100,100))); 
+5

왜 C++ 프로그램에서'malloc'을 사용하려고합니까? –

답변

6

아니요, 올바른 방법은 아닙니다. malloc에는 C++ 프로그램이 전혀 없습니다. 객체를 할당하는 올바른 방법은 다음과 같이이다 :

fmat squareMat(100, 100); 

쉽게 reading the documentation 볼 수 있습니다.