I have two instances of structs.
struct Foo{ ... }
1 2
|
Foot1 *foo1Instance = new Foo1();
Foot1 *foo2Instance = new Foo1();
|
i populate *foo2Instance with stuff....
then I want to copy over foo2Instance content to foo1Instance then delete
foo2Instance because i don't need it anymore...
so i have something like:
1 2
|
*foo1Instance = *foo2Instance
delete foo2Instance;
|
..do stuff with foo1Instance new data from foo2Instance.
problem is when i try to access foo1Instance , it throws exceptions,..however if i don't delete foo2Instance its fine...so
*foo1Instance = *foo2Instance
is not write..i tried std::swap,doesn't work..... if i never delete foo2Instance, things work....
can someone tell me how to copy my struct to the other, and safety & completely delete the other one and not have it effect foo1instance?