About Store Forum Documentation Contact



Post Reply 
Any differnece between STRUCT and class?
Author Message
Snajpa Offline
Member

Post: #1
Any differnece between STRUCT and class?
Just quick question

Code:
class ClassName : public Game::Chr
{
public:
   virtual Bool update();
};

This will work as same as
Code:
STRUCT(Namehere, Game::Chr)
//{
virtual Bool update();
};

?
(This post was last modified: 10-30-2011 04:51 PM by Snajpa.)
10-30-2011 04:42 PM
Find all posts by this user Quote this message in a reply
rndbit Offline
Member

Post: #2
RE: Any differnece between STRUCT and class?
stuff in struct is public by default so you dont need 'public:' bit. other than that - its exactly the same (except for how it looks in the code, macro aint pretty..)
10-30-2011 06:22 PM
Find all posts by this user Quote this message in a reply
Snajpa Offline
Member

Post: #3
RE: Any differnece between STRUCT and class?
Ok thanks wink
10-30-2011 07:43 PM
Find all posts by this user Quote this message in a reply
Dwight Offline
Member

Post: #4
RE: Any differnece between STRUCT and class?
There are also some optimization-things that you should look up between a struct and a class; so they are in fact not exactly the same (except for the public/private defaults difference).

Sometimes a struct is preferred over a class or vice versa.

SnowCloud Entertainment - We are recruiting!
http://www.sc-entertainment.com
(This post was last modified: 10-30-2011 09:52 PM by Dwight.)
10-30-2011 09:40 PM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #5
RE: Any differnece between STRUCT and class?
rndbit is right about struct vs class, however the purpose of STRUCT (the macro) is to maintain cross-platformability. If you plan on releasing your game on the Mac or iOS devices, you will need to use STRUCT when extending EE classes. This is because __super is not available under the GCC compiler (Wiki page).

Also, I agree with rndbit, the macro ain't pretty..
(This post was last modified: 10-31-2011 06:31 AM by Driklyn.)
10-31-2011 06:29 AM
Find all posts by this user Quote this message in a reply
Snajpa Offline
Member

Post: #6
RE: Any differnece between STRUCT and class?
Ok now I understand everything. Thanks all wink
(This post was last modified: 10-31-2011 11:42 AM by Snajpa.)
10-31-2011 11:41 AM
Find all posts by this user Quote this message in a reply
rndbit Offline
Member

Post: #7
RE: Any differnece between STRUCT and class?
(10-30-2011 09:40 PM)Dwight Wrote:  There are also some optimization-things that you should look up between a struct and a class; so they are in fact not exactly the same (except for the public/private defaults difference).

Sometimes a struct is preferred over a class or vice versa.

like what optimizations?
11-07-2011 05:09 PM
Find all posts by this user Quote this message in a reply
Dwight Offline
Member

Post: #8
RE: Any differnece between STRUCT and class?
On runtime, there have been tests (you can google them) in which the difference is just a couple of seconds in 2.5 million calls.

In addition to that, the following link can be of help:
http://geekswithblogs.net/mahesh/archive...93753.aspx

These performance issues are not even worth considering in a project, but there IS a difference in performace, even if it is suuuuuper small (to the extent of my knowledge).

SnowCloud Entertainment - We are recruiting!
http://www.sc-entertainment.com
11-07-2011 08:06 PM
Find all posts by this user Quote this message in a reply
rndbit Offline
Member

Post: #9
RE: Any differnece between STRUCT and class?
that link - wrong language. we are dealing with c++ here.
11-08-2011 07:09 PM
Find all posts by this user Quote this message in a reply
Post Reply