473,471 Members | 1,964 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Differences in C++ between struct and class

Hi,
I have just read that struct's in C++ can have public and private
members, so I have one question:
Which are the differences between classes and structs (besides
constructors and destructors?).
Thanks.

May 30 '07 #1
2 1599
Javier wrote:
Hi,
I have just read that struct's in C++ can have public and private
members, so I have one question:
Which are the differences between classes and structs (besides
constructors and destructors?).
Thanks.
There is no difference with regard to constructors and destructors. The
only difference is the default access and inheritance is public for a
struct and private for a class.

--
Ian Collins.
May 30 '07 #2
On 30 May, 09:43, Javier <jjeron...@gmail.comwrote:
Hi,
I have just read that struct's in C++ can have public and private
members, so I have one question:
Which are the differences between classes and structs
Almost nothing.
(besides constructors and destructors?).
That's not a difference. structs have constructors and destructors,
either compiler generated or written by you, in exactly the way
classes do.

Your answer is in the FAQ.
http://www.parashift.com/c++-faq-lit...s.html#faq-7.8
The differences described in the first sentence of that FAQ are the
*only* technical differences between a struct and a class. But do note
the rest of the FAQ that describes the different ways the two are
generally used.

Gavin Deane

May 30 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Bern | last post by:
what are all the diferences between the two?
22
by: BekTek | last post by:
Hi.. I'm so sorry about that I've postes so many questions recently.. :) I'm still confused about the differences between malloc and operator new.. I know that when we work with class object and...
6
by: gustav04 | last post by:
hi all i have a question: what is the difference between a c-function and an c++ class method (both do exactly the same thing). lets say, i have a function called print2std() and a class...
12
by: Jason Curl | last post by:
Hello, Just a clarification of the specification about the C-Standard's interpretation of pointers. I know that 'char *' and 'void *' are equivalent and that 'int *' may be different in...
15
by: Paul Morrison | last post by:
Hi all, I need to come up with some differences between arrays in Java and C, I have searched Google and so far all I have found is the following: Arrays in Java are reference types with...
11
by: blangela | last post by:
I am teaching a C programming course to C++ programmers and want to come up with list of _KEY_ differences between the two languages. Below is a list I have come up with so far. Have I missed any?...
2
by: Ninereeds | last post by:
I'm messing around with using mixin-layers (look for papers by Yannis Smaragdakis and Don Batory) to define data structures. One issue is that nodes tend to have pointers to other nodes - the...
9
by: chikkubhai | last post by:
Why is the result different for the following set of two code snippets Code without using this pointer #include <string> #include <iostream> using namespace std; struct X { private:
4
by: puzzlecracker | last post by:
what are the most usable, prominent, and must-to-know ones?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.