Solved

struct

Posted on 2001-06-23
5
322 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:sedgwick
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 20 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

785 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