C++ For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming

 < 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 > 

Категории