Snajpa
Member
|
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 |
|
rndbit
Member
|
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 |
|
Dwight
Member
|
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 |
|
Driklyn
Member
|
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 |
|
rndbit
Member
|
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 |
|
Dwight
Member
|
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 |
|
rndbit
Member
|
RE: Any differnece between STRUCT and class?
that link - wrong language. we are dealing with c++ here.
|
|
11-08-2011 07:09 PM |
|