この例を見てください:
class Foo {
private:
const std::string m_str1;
const std::string m_str2;
std::string foo() {
std::cout << ("'" + m_str2 + "'") << std::endl;
return "whatever1";
}
public:
Foo() : m_str1(foo()), m_str2("whatever2") { }
};
int main() {
Foo foo;
return 0;
}
私のコンピューターでは、コンストラクターリストが実行される前にm_str2が実際に値が空の文字列に初期化されたことを示す''(2つの一重引用符が次々に)を出力します。
しかし、それは一般的に本当ですか?