The Differences Between Structures Classes

 < Day Day Up > 



The Differences Between Structures & Classes

The differences between structures and classes are summarized in table 10.1.

Table 10-1: Differences Between Structures and Classes

Feature

Structures

Classes

Keyword

struct

class

Default member access

public

private

Used in object-oriented thinking

No

Yes

Pretty big table! If structures are used at all by C++ programmers it is to reinforce the notion that the type they are creating is a simple aggregation. Using structs in this manner does not go against the grain of object-oriented programming per se, but, as I said earlier, anything you can do with a struct can be done with a class.

Quick Summary

The syntactic and semantic differences between structures and classes lies in their keywords and default member accessibility. How you think about programming with each makes all the difference in the world. To say more about their differences would belabor the point!



 < Day Day Up > 



C++ for Artists. The Art, Philosophy, and Science of Object-Oriented Programming
C++ For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504028
EAN: 2147483647
Year: 2003
Pages: 340
Authors: Rick Miller

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net