Archived

This topic is now archived and is closed to further replies.

Mauzoleum

Performance question

Recommended Posts

Hello! I am writing 3D application and i will need vectors. Now i have:
      
struct stVector
{
float x;
float y;
float z;
}
  
but i want do do classes like
        
class cVector
{
public:
float x;
float y;
float z;

cVector();
~cVector();
void Normalize(void);
};
  
Now if i declarate vector i for example write "float Pos=Vector.x" it will be faster for structure/class or maybe it will be exacly the same performance? Thank you for your answers. [edited by - Mauzoleum on January 18, 2003 9:18:31 PM] [edited by - Mauzoleum on January 18, 2003 9:19:50 PM]

Share this post


Link to post
Share on other sites
Go with the class. They are the same speed, and the same size in memory (unless you have virtual functions).


Only use structs if you don''t need to have any functions/constructors/destructors.

(That last bit is just my opinion though.)

Share this post


Link to post
Share on other sites