Performance question

Started by
2 comments, last by Mauzoleum 21 years, 3 months ago
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]
Advertisement
A structure is a class with all public members.
Keys to success: Ability, ambition and opportunity.
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.)
The performance will be the same. Think about it: why wouldn''t it be?

This topic is closed to new replies.

Advertisement