By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,513 Members | 1,653 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,513 IT Pros & Developers. It's quick & easy.

Differences in C++ between struct and class

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.