Original Post
A few years ago I wrote a rigid body simulator. Now I'm trying to port it to linux (gcc) but I'm having some trouble with references. I know found out that VC++ lets you pass temporary values by reference and gcc doesn't (according to the standard). So I have many places in my code were I do things like this: What's the best way to port this? do I have to change the function so that it accepts pointers instead of references and then do something like: RigidBody *b = new RigidBody(...); Simulation.AddBody(b); Or is there an easier way? I'd be great if I didn't have to go through the entire code and change all references to pointers. Thanks. [/source]
//stripped down class
class Simulation{
vector<RigidBody> Bodies;
vector<unsigned int> BodyIndexs;
void AddBody(RigidBody &Body){Bodies.push_back(Body);
BodyIndexs.push_back(Bodies.size()-1);}
vector<RigidBody> GetBodies(){return Bodies;}
};
//then somewere in the program (Simulation is an object of type "Simulation")
Simulation.AddBody(RigidBody(...));