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
apointer has finished allocating.New works as follows (oversimplified)
So in your case
This ignores cases involving exceptions..