행렬 초기화에 대한 무슨 오류인지 모르겠습니다...ㅜ
#include <cstdlib> #include <iostream> #include <conio.h> #include <windows.h> #include <gl/gl.h> #include <gl/glu.h> #include <gl/glut.h> #include <stdlib.h> #include <time.h> #include <math.h> #include <stdio.h> //(생략).. Matrix::Matrix() { m[3][3]= { {1, 0, 0}, {0, 1, 0}, {0, 0, 1} }; } // (생략)
1>c:\program files\microsoft visual studio\myprojects\hw00\3x3matrix.cpp(6) : error C2059: 구문 오류 : '{'
1>c:\program files\microsoft visual studio\myprojects\hw00\3x3matrix.cpp(6) : error C2143: 구문 오류 : ';'이(가) '{' 앞에 없습니다.
1>c:\program files\microsoft visual studio\myprojects\hw00\3x3matrix.cpp(7) : error C2143: 구문 오류 : ';'이(가) '}' 앞에 없습니다.
1>c:\program files\microsoft visual studio\myprojects\hw00\3x3matrix.cpp(7) : error C2143: 구문 오류 : ';'이(가) ',' 앞에 없습니다.
1>c:\program files\microsoft visual studio\myprojects\hw00\3x3matrix.cpp(8) : error C2143: 구문 오류 : ';'이(가) '{' 앞에 없습니다.
1>c:\program files\microsoft visual studio\myprojects\hw00\3x3matrix.cpp(8) : error C2143: 구문 오류 : ';'이(가) '}' 앞에 없습니다.
1>c:\program files\microsoft visual studio\myprojects\hw00\3x3matrix.cpp(8) : error C2143: 구문 오류 : ';'이(가) ',' 앞에 없습니다.
1>c:\program files\microsoft visual studio\myprojects\hw00\3x3matrix.cpp(9) : error C2143: 구문 오류 : ';'이(가) '{' 앞에 없습니다.
1>c:\program files\microsoft visual studio\myprojects\hw00\3x3matrix.cpp(9) : error C2143: 구문 오류 : ';'이(가) '}' 앞에 없습니다.
여기서 왜 다음과 같은 행렬 오류가 나는지 모르겠습니다.. 해결책좀 알려주시기 바랍니다. ㅜ
혹시 opengl 행렬을
혹시 opengl 행렬을 쓰신 건 아닌가요?
...
m 앞에 타입이 없네요. double m[3][3] = { { ... 이런 식으로 쓰시면 유혈사태^H^H^H^H컴파일 에러는 일어나지 않을 것입니다.
참 이런 에러는
참 이런 에러는 자기눈에는 절대 안보이죠^^
인생은 도박이다.
타입은 당연히 선언 했습니다..
타입을 클래스 내부에 이미 선언한 바 있습니다. 보시다시피
생성자에서 초기화를 하기 위해 배열을 정의하는 거구요..
왜 안되는지 잘 모르겠습니다.. openGl 에서는 배열 초기화가 안되는 거였나여?
선언부좀 보여줘
선언부좀 보여줘 봐요.
...
저런 식으로 배열 변수를 초기화하는 건 원래 변수를 정의하는 순간에만 가능한 문법으로 알고 있습니다만... (혹시 제가 모르는 새 문법이 바뀌었을라나요..?)
OpenGL이 아니라 OpenGL 할아비가 온다 한들 없는 문법을 만들어낼 수야...
클래스 선언부에
클래스 선언부에 변수가 선언이 되어있다면
정의할 때는 그런 문법으로 쓸 수 없습니다.
m[0][0]=..
m[0][1]=..
..
m[2][2]=..
이런 식으로 일일이 다 정해주셔야 합니다.
------------------------------
How many legs does a dog have?
------------------------------
How many legs does a dog have?
아 그렇군요.. 소중한 댓글 감사합니다^^
아 그렇군요.. 소중한 댓글 감사합니다^^
댓글 달기