variable declarations in c++ - what am I doing wrong?

downhiller80

Platinum Member
Apr 13, 2000
2,353
0
0
I'm writing a physics simulation that when run takes up 50Meg! This isn't right! I think my problem lies in declaring variables inside a function that is called many thousands of times a second, but how do I get round this without using global variables?

cheers

seb
 

downhiller80

Platinum Member
Apr 13, 2000
2,353
0
0
www.icmtb.co.uk/spheres.h

I'm thinking it's all the repeated definitions that happen in the last function. I don't know much about c++ yet, should I be using static variables or something? I just hope it's not pointers...

cheers

seb
 

Descartes

Lifer
Oct 10, 1999
13,968
2
0
Any particular reason you like to implement every method of a class in the class declaration?

I'd say first start off with moving _all_ of the method implementations into a single translation unit. Inline code is usually reserved for short, simple methods, like accessor functions, etc.
 

downhiller80

Platinum Member
Apr 13, 2000
2,353
0
0
er, that's just the way i've been taught... can you tell me what you're talking about cos I haven't a clue!


seb