#include <iostream>
using namespace std;
class Apple
{
public:
int i;
string s = "HelloWorld";
string s1;
bool b;
};
int main(int argc, char *argv[]) {
Apple a; //doesn't this trigger default initialization??
cout << a.i << a.s << a.s1 << a.b;
}
オブジェクトがローカル変数の場合、データメンバーはデフォルトで初期化されます。しかし、ここに出力があります:0HelloWorld0
。この値の初期化ではありませんか?