0
하단의 코드를 컴파일하는 데 문제가 있습니다. 항상 C
로하고 있지만, 반 내면 C++
에서 할 수 없습니다. 누군가가 나에게 여기 계신 것을 나에게 깨달을 수 있습니까?클래스 내부에서 구조체를 정의하는 방법은 무엇입니까?
class Parser {
struct table {
string first;
string second;
string third;
} c_table [] = {
"0","a","b",
"0","c","d",
"0","e","f",
};
};
int main() {
return 0;
}
test.cpp:22:3: error: too many initializers for ‘Parser::table [0]’
test.cpp:22:3: error: could not convert ‘(const char*)"0"’ from ‘const char*’ to ‘Parser::table’
test.cpp:22:3: error: could not convert ‘(const char*)"a"’ from ‘const char*’ to ‘Parser::table’
test.cpp:22:3: error: could not convert ‘(const char*)"b"’ from ‘const char*’ to ‘Parser::table’
test.cpp:22:3: error: could not convert ‘(const char*)"0"’ from ‘const char*’ to ‘Parser::table’
test.cpp:22:3: error: could not convert ‘(const char*)"c"’ from ‘const char*’ to ‘Parser::table’
test.cpp:22:3: error: could not convert ‘(const char*)"d"’ from ‘const char*’ to ‘Parser::table’
test.cpp:22:3: error: could not convert ‘(const char*)"0"’ from ‘const char*’ to ‘Parser::table’
test.cpp:22:3: error: could not convert ‘(const char*)"e"’ from ‘const char*’ to ‘Parser::table’
test.cpp:22:3: error: could not convert ‘(const char*)"f"’ from ‘const char*’ to ‘Parser::table’
문제 발생은 전체 오류를 포함해야 함을 의미합니다. – chris
C++ 11을 사용하고 있습니까? – jrok
@chris : 오류 – Mark