The C++Course provides a general introduction to programming in C++. It is based on A.B. Downey's book, How to Think Like a Computer Scientist. Click here for details. |
![]() |
Home ![]() ![]() |
||
![]() ![]() ![]() ![]() ![]() ![]() |
||
Compound Values
Most of the data types we have been working with represent a single value---an integer, a floating-point number, a boolean value. pstrings are different in the sense that they are made up of smaller pieces, the characters. Thus, pstrings are an example of a compound type. Depending on what we are doing, we may want to treat a compound type as a single thing (or object), or we may want to access its parts (or instance variables). This ambiguity is useful. It is also useful to be able to create your own compound values. C++ provides two mechanisms for doing that: structures and classes. We will start out with structures and get to classes (there is not much difference between them).
|
||
Home ![]() ![]() |