Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C++
Expertise: Beginner
Jan 8, 1999

Difference between structures & classes

Question:
Why use classes when the same can be implemented using structures?

Answer:
Reasonable question. For starters, structures in C could not work like classes. Classes were needed to implement object-oriented programming. Then it looks like the designers of C++ decided they might as way give the class functionality to structures as well (which are similiar to classes).

I don't know all the thinking that went into that, but the two are very similar. The primary difference is that, by default, structure members are public (can be accessed by code that references the structure), while class members are private (which is more in line with the OOP approach).

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date