Eric
Member
|
Differences between Class and Struct Object
Hello!
I have a quick question to you guys. Is there any difference between Object created from Struct and Class ? Any kind of performance differences ? I've noticed that EE uses Structs not Classes therefore I'm curious about this. Why Structs not Classes ? I've heard that I should use Structs for some kind of 'smaller' objects like struct Vec2 {}; and Classes for 'bigger' like class Player {}; - is that true ? Is there any 'C++ standard' for this ?
Regards,
Eric 'Eri' Przychocki
ourgames.eu
|
|
05-07-2013 10:22 AM |
|
Tottel
Member
|
RE: Differences between Class and Struct Object
Usually, structs are used to store data (like Vec2 storing an X and a Y position).
You would use classes to create objects in-game (storing both variables and functions).
Technically, a class is a struct though. By default, a struct has its access set to public, a class to private.
I don't think there would be any noticeable performance difference.
|
|
05-07-2013 10:57 AM |
|
Eric
Member
|
RE: Differences between Class and Struct Object
that's what I thought. thanks for the fast reply
P.S. if I have a overloaded constructor and operators in struct Color should it be still struct or class then ?
Regards,
Eric 'Eri' Przychocki
ourgames.eu
|
|
05-07-2013 11:02 AM |
|
Esenthel
Administrator
|
RE: Differences between Class and Struct Object
struct is the same as class in c++ except that it defaults to "public" while class defaults to "private" members and bases.
I always stick to struct because I list public members first in the "struct/class declaration"
However in Code Editor I've made "class" work exactly the same as C++ struct.
|
|
05-07-2013 11:31 AM |
|
kasinova
Member
|
RE: Differences between Class and Struct Object
there is one difference I've found:
when you CAST() it doesn't cast to classes only STRUCT
|
|
05-07-2013 06:17 PM |
|