If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: Basic Data Persistance question

Yes, I was. I tried my best and still cannot completely grasp the concept. Sorry for the waste of effort. :*(
Smart pointers would manage the copying of resources?
Also, should I replace raw pointers with shared_ptr's as much as possible?
Thirdly, shared_ptr's would share the ownerships between multiple objects?
I don't quite get the benefits of smart pointers anyways in general if it still collapses the program when I use it

What you see in red are all local variables and your usage of them. When that Load function returns, those variables no longer exist. Are you still attempting to use "frames" or "mesh" in another function? If so, then that is no good. Local variables are just that -- local. Trying to point to them and use them after they've gone up in smoke is not going to work.

Also, you should have posted a main() program showing exactly how you're using these classes. Just showing classes and code where we have no idea what happened previously doesn't help.

Re: Basic Data Persistance question

Originally Posted by Paul McKenzie

The problem is that shape has an invalid pointer.
What you see in red are all local variables and your usage of them. When that Load function returns, those variables no longer exist. Are you still attempting to use "frames" or "mesh" in another function? If so, then that is no good. Local variables are just that -- local. Trying to point to them and use them after they've gone up in smoke is not going to work.

Also, you should have posted a main() program showing exactly how you're using these classes. Just showing classes and code where we have no idea what happened previously doesn't help.

Re: Basic Data Persistance question

Originally Posted by lucky6969b

Where should I store the actual solid object of Mesh, in your opinion?

The issue is that your "solid object" is not solid. It is a local variable that goes out of scope on return. The code you wrote is honestly just plain wrong. It isn't even a matter of design -- you can't return or refer to addresses or references to local variables after the function block that declares them is exited.

Either create it dynamically (preferably using a smart pointer), or one of your objects must have as a member a Mesh, so that it does not go out of scope.