Skip to main content
gamedev.net
🔒 Locked

Performance question

Started by Mauzoleum Jan 18, 2003 at 8:16 PM 2 replies 150+ views
Original Post
Mauzoleum
Mauzoleum
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]
LilBudyWizer
LilBudyWizer
A structure is a class with all public members.
Keys to success: Ability, ambition and opportunity.
Nypyren
Nypyren
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.)
Beer Hunter
Beer Hunter
The performance will be the same. Think about it: why wouldn''t it be?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.