About Store Forum Documentation Contact



Post Reply 
Differences between Class and Struct Object
Author Message
Eric Offline
Member

Post: #1
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 ? wink

Regards,
Eric 'Eri' Przychocki
ourgames.eu
05-07-2013 10:22 AM
Find all posts by this user Quote this message in a reply
Tottel Offline
Member

Post: #2
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
Find all posts by this user Quote this message in a reply
Eric Offline
Member

Post: #3
RE: Differences between Class and Struct Object
that's what I thought. thanks for the fast reply smile
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
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
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
Find all posts by this user Quote this message in a reply
kasinova Offline
Member

Post: #5
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
Find all posts by this user Quote this message in a reply
Post Reply