Link to home
Start Free TrialLog in
Avatar of plamtod
plamtod

asked on

struct

Hi,
I saw code like this:
struct CFoo:public CGoo
{
....
}
Is there difference if was "class" and what?
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

yes, the difference is for example by using 'private' and 'public' in a class
The main difference between a struct and a class is that in a struct, the members are by default public.  Bur in a class, the memeber are private unless you use public:

struct MyStruct : public MyOtherStruct
{
  int nThisIsPublic;
};

class MyClass : public MyOtherClass
{
  int nThisIsPrivate;
public:
  int nThisIsPublic;
}

See:
http://msdn.microsoft.com/library/en-us/vccore98/HTML/_langref_struct.asp

and
http://msdn.microsoft.com/library/en-us/vccore98/HTML/_langref_private.asp

-- Dan
Avatar of plamtod
plamtod

ASKER

If I use struct I suppose members are called by "." not "->" and members of base class too?
ASKER CERTIFIED SOLUTION
Avatar of DanRollins
DanRollins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of plamtod

ASKER

Thanx Dan