-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
had a great question about the + operator. In that operator I have
Vector temp(size+rhs.size);
//do the copy of lhs and rhs into temp and return it.
Then I have something like
c=a+b;
at the end of the + operator the temp vector should have its destructor called. What happens when we assign the result of a+b to c? Has the memory in temp already been freed? I added some print statements and it turns out, that temp isn't destroyed until after its data is copied over to c, or after the assignment operator completes.
Maybe this would be a good exercise
Metadata
Metadata
Assignees
Labels
No labels