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
Solved

struct

Posted on 2001-06-23
5
330 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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 shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

828 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