Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,158 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,100 people online right now. Registration is fast and FREE... Join Now!




I dont need a program....i just need to know the difference

 
Reply to this topicStart new topic

I dont need a program....i just need to know the difference, Classes,Structures, union

manurulzforever
13 Dec, 2007 - 10:26 PM
Post #1

New D.I.C Head
*

Joined: 13 Dec, 2007
Posts: 3


My Contributions
Can anyone please help me understand what exactly are classes, unions and structures......
if not possible please provide suitable links to websites.
If possible could you please provide suitable examples to show how they are used.
I would be really grateful if you could
User is offlineProfile CardPM
+Quote Post

Bench
RE: I Dont Need A Program....i Just Need To Know The Difference
14 Dec, 2007 - 04:33 AM
Post #2

D.I.C Addict
Group Icon

Joined: 20 Aug, 2007
Posts: 617



Thanked: 14 times
Dream Kudos: 150
Expert In: C/C++

My Contributions
Your C++ Book ought to explain these things in depth. If you haven't got a C++ book, have a look at Bruce Eckel's free e-book, Thinking in C++ Vol 1.
http://mindview.net/Books/TICPP/ThinkingInCPP2e.html


in the meantime, the first half of this page explains the struct keyword
http://www.cplusplus.com/doc/tutorial/structures.html
User is offlineProfile CardPM
+Quote Post

Bench
RE: I Dont Need A Program....i Just Need To Know The Difference
14 Dec, 2007 - 04:41 AM
Post #3

D.I.C Addict
Group Icon

Joined: 20 Aug, 2007
Posts: 617



Thanked: 14 times
Dream Kudos: 150
Expert In: C/C++

My Contributions
ad. - the syntax and usage of class and struct are identical for all intents and purposes.

As you explore object-oriented programming, the terms 'public' and 'private' will creep in (Although, don't worry about them for now). Just for future reference, the only difference between a struct and a class in C++, is that a class defaults everything to private, wheras a struct defaults everything to public.
User is offlineProfile CardPM
+Quote Post

mattman059
RE: I Dont Need A Program....i Just Need To Know The Difference
14 Dec, 2007 - 07:03 AM
Post #4

D.I.C Regular
Group Icon

Joined: 23 Oct, 2006
Posts: 340


Dream Kudos: 175
My Contributions
structs are usefull for programs in which you need a small set of similar data (say a student program, where you only need a name, gpa, and ID#) You COULD use a class to define it, but a struct would be simpler. A Class is used for larger programs where you would want to have data, and functions that work together.

Another type that you could look into are Enums (or enumerated data) they are usefull in creating dictionaries and things like that
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 11:36PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month