| < Day Day Up > |
|
The differences between structures and classes are summarized in table 10.1.
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.
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 > |
|