C++에서는 여유 오브젝트의 초기화 순서가 정의되지 않습니다. 그러나 다음은 어떨까요?정적 초기화시 free "char const *"사용
namespace foo {
char const* str = "hey";
struct A {
A() { cout << str; }
} obj;
}
아직 정의되지 않은 동작입니까, 아니면 문자열 리터럴로 초기화 된 포인터에 대한 특수 조항이 있습니까?
그 외에도 : str이 "char const []"유형 인 경우 어떻게해야합니까? 그리고 그것이 std :: string이라면?
내 잘못 알겠습니다. –
-1 : 잘못되었습니다. http://stackoverflow.com/questions/8750407/do-objects-of-built-in-types-have-special-static-initialisation-order-precedence를 참조하십시오. –