plamtod
asked on
struct
Hi,
I saw code like this:
struct CFoo:public CGoo
{
....
}
Is there difference if was "class" and what?
I saw code like this:
struct CFoo:public CGoo
{
....
}
Is there difference if was "class" and what?
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
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
ASKER
If I use struct I suppose members are called by "." not "->" and members of base class too?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanx Dan