Solved

struct

Posted on 2001-06-23
5
304 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
Comment Utility
yes, the difference is for example by using 'private' and 'public' in a class
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanx Dan
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
if loop error 4 76
Looking for a specific application/software 2 91
iSeries DB2 Query 2 83
wordcount challenge 11 72
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now