Current location: Hot Scripts Forums » Programming Languages » C/C++ » Difference between c and c++ structure


Difference between c and c++ structure

Reply
  #11 (permalink)  
Old 01-20-07, 08:25 AM
King Coder King Coder is offline
Community VIP
 
Join Date: Jan 2006
Posts: 703
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by balkman
Tell how they are different other than their default access type. Anything you can do with a class you can do with a structure.
Classes are passed through reference while structures are passed through value.

Classes are inherited privately by default. Structs are inherited publicly.

Structs by convention normally don't contain functions and are carried over from C. C didn't have classes. Structs are a C thing. Remember, no member functions or constructors in C.


The only way I would use a struct is if I were communicating with an old API, working with a legacy program or modeling a simple POD type.

I simply prefer using class. Afterall, the default access is not a negligable thing and the keyword class is much more fitting.
__________________
my site
Reply With Quote
  #12 (permalink)  
Old 01-20-07, 08:28 AM
King Coder King Coder is offline
Community VIP
 
Join Date: Jan 2006
Posts: 703
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
You might be thinking of C# or Java
hmm... could be.

No matter what, the differences are very small. C# has a wider margin of changes.
__________________
my site
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 04:38 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.