Solved

struct

Posted on 2001-06-23
5
338 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Title # Comments Views Activity
Process filename extension 3 208
ffmpeg - "rtsp://...... Operation not permitted" 4 88
modThree challenge 4 103
Detect file exist or not 3 198
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 …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.

685 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