const char[] test = "test";
Str ret(test);
을 컴파일하니
3.cpp:12:15: error: expected unqualified-id before ‘[’ token
const char[] test = "test";
^
3.cpp:13:13: error: ‘test’ was not declared in this scope
Str ret(test);
와 같은 에러가 발생하는데, 도통 이유를 모르겠습니다.
const char[] test = "test";
Str ret(test);
을 컴파일하니
3.cpp:12:15: error: expected unqualified-id before ‘[’ token
const char[] test = "test";
^
3.cpp:13:13: error: ‘test’ was not declared in this scope
Str ret(test);
와 같은 에러가 발생하는데, 도통 이유를 모르겠습니다.
const char* test = "test"; 자바랑 다릅니다.
미리 배열 사이즈를 입력하지 않고 char[] test 로는 변수 선언이 불가능한건가요?
배열 사이즈를 자동으로 인식하여 새로운 메모리 공간을 할당해 새 메모리 공간의 주소를 저장하는 줄 알았는데, 이 부분이 잘못된건가요??
const char test+ = "test"; 는 가능
배열 사이즈를 자동으로 인식하여 새로 할당은 안되는거로 알고있읍니다. 유사한걸 쓰시려면 벡터를 쓰셔야하는데 벡터는 저도 공부해야해서 알려드릴게 없네요
const char test[] = "test"; 이건 되는지 모르겠네요 될지도 모르겠네요
감사합니다~~!!