?
Solved

struct

Posted on 2001-06-23
5
Medium Priority
?
356 Views
Last Modified: 2013-11-20
Hi,
I saw code like this:
struct CFoo:public CGoo
{
....
}
Is there difference if was "class" and what?
0
Comment
Question by:plamtod
  • 2
  • 2
5 Comments
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 6222463
yes, the difference is for example by using 'private' and 'public' in a class
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6222489
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
0
 

Author Comment

by:plamtod
ID: 6222540
If I use struct I suppose members are called by "." not "->" and members of base class too?
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 80 total points
ID: 6222549
In both cases, . and -> are used the same.  . is member of structure and -> is member of pointer-to structure.  This is C++ 101


See:
Structure, Union, and Class Member Operators: . and ->
http://msdn.microsoft.com/library/en-us/vccore98/HTML/_langref_structure.2c_.union.2c_.and_class_member_operators.3a_.._.and_.2d3e.asp

-- Dan
0
 

Author Comment

by:plamtod
ID: 6222581
Thanx Dan
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question