Dynamically allocating new object in constructor
So given this simple scenario: class A{ public: A(){ n = new int(10); } ~A(){ delete n; } int* n; }; int main(){ A* a = new A(); } Can this cause heap corruption (problems in general), since a-pointer hasn't finished allocating, while I'm making a new allocation? If so, using std::vector inside heap constructors in also prohibited, right? Thank you. Your a pointer has finished allocating . New works as follows (oversimplified) Allocate Construct So in your case Allocate A Construct A Allocate int Construct int - initialize Finish Construct A This ignores cases involving exceptions.. There is