Skip to main content
GameDev.net gamedev.net
🔒 Locked

struct versus class

Started by zychrias Sep 24, 2004 at 1:24 AM 3 replies 950+ views
Original Post
zychrias
zychrias
In my Google, Gamedev.net, and in books I've seen the only difference between Struct and Class is the private and public modifiers. What am I asking is if there are any other differences such as memory requirements and the usual noticable differences in how they are laid out?
snk_kid
snk_kid
There is no difference, just struct default to public access & inheritance while class default to private.
Qw3r7yU10p!
Qw3r7yU10p!
As snk_kid said.

Also I've found that with microsoft's compiler, if you forward declare something it has to be the same as the actual declaration and previous forward declarations. So in MSVC you can't have a class and forward declare it as a struct. I'm not sure whether this is standard or not.

class Jigger;
class Jigger;//multiple forward declarations are fine
struct Jigger;//not allowed in MSVC

Also, as always, see the C++ FAQ Lite
saladyears
saladyears
Hmm, in my VC .NET 2003, it lets me compile mismatched forward declarations, but gives me warning C4099.
Qw3r7yU10p!
Qw3r7yU10p!
I should have said my (work) compiler is VC++ 6.0

Topic Locked

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

Sign in to reply to this topic.