struct Obj { int a; int b; };Obj* obj = new Obj(); obj: 0x9030 obj->a: 0x9030 + 0x0 obj->b: 0x9030 + 0x4Obj* obj = nullptr; obj: 0x9030 obj->a: 0x9030 + 0x0 obj->b: 0x9030 + 0x4 zsh: segmentation fault ./null
Das muĂź natĂĽrlich lauten
Obj* obj = nullptr;
obj: 0x0
obj->a: 0x0 + 0x0
obj->b: 0x0 + 0x4
zsh: segmentation fault ./null
Ich bitte doch um etwas mehr Sorgfalt. Bei diesem kurzen Beispiel könntet ihr auch den vollständigen Code bereitstellen und das Problem anhand dessen erklären.
Besten Dank
pre alpha