행렬 초기화에 대한 무슨 오류인지 모르겠습니다...ㅜ

victoryz12의 이미지

#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: 구문 오류 : ';'이(가) '}' 앞에 없습니다.
여기서 왜 다음과 같은 행렬 오류가 나는지 모르겠습니다.. 해결책좀 알려주시기 바랍니다. ㅜ

ifree의 이미지

혹시 opengl 행렬을 쓰신 건 아닌가요?

jick의 이미지

m 앞에 타입이 없네요. double m[3][3] = { { ... 이런 식으로 쓰시면 유혈사태^H^H^H^H컴파일 에러는 일어나지 않을 것입니다.

런맨의 이미지

참 이런 에러는 자기눈에는 절대 안보이죠^^

인생은 도박이다.

victoryz12의 이미지

타입을 클래스 내부에 이미 선언한 바 있습니다. 보시다시피

생성자에서 초기화를 하기 위해 배열을 정의하는 거구요..

왜 안되는지 잘 모르겠습니다.. openGl 에서는 배열 초기화가 안되는 거였나여?

ifree의 이미지

선언부좀 보여줘 봐요.

jick의 이미지

저런 식으로 배열 변수를 초기화하는 건 원래 변수를 정의하는 순간에만 가능한 문법으로 알고 있습니다만... (혹시 제가 모르는 새 문법이 바뀌었을라나요..?)

OpenGL이 아니라 OpenGL 할아비가 온다 한들 없는 문법을 만들어낼 수야...

semmal의 이미지

클래스 선언부에 변수가 선언이 되어있다면

정의할 때는 그런 문법으로 쓸 수 없습니다.

m[0][0]=..
m[0][1]=..
..
m[2][2]=..

이런 식으로 일일이 다 정해주셔야 합니다.
------------------------------
How many legs does a dog have?

------------------------------
How many legs does a dog have?

victoryz12의 이미지

아 그렇군요.. 소중한 댓글 감사합니다^^

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.