Posted on 2001-06-23
Last Modified: 2013-11-20
I saw code like this:
struct CFoo:public CGoo
Is there difference if was "class" and what?
Question by:plamtod
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 42

Expert Comment

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

Expert Comment

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;
  int nThisIsPublic;



-- Dan

Author Comment

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

Accepted Solution

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

Structure, Union, and Class Member Operators: . and ->

-- Dan

Author Comment

ID: 6222581
Thanx Dan

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Creating Labels and Frequency list style reports in SAS code 9 128
Detect file exist or not 3 215
Work with App store 7 120
moto 4g phone enable finger print 4 72
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.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

737 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