Summary

 < Day Day Up > 



You can abstract the problem you are solving with a computer by declaring synonyms for existing data types or designing your own. The typedef keyword lets you create a synonym for an existing data type making it better suited to represent your problem domain. Enumerations are new types that allow integer values to be referenced by name. Your compiler can be set to ensure you don’t try to assign an unauthorized state value to an enumerated type variable, thus reducing the risk of making programming errors while at the same time making your source code easier to read and manage.

Structures can be used in two ways: C-style, where only data members are contained in the structure, or C++- style, where both data members and functions are placed in the structure. The C-style method of using structures is based on a procedural programming mind set where data structures are defined separate from the functions that manipulate those structures. It is a good idea to understand the C-style method in case you have to maintain legacy C code.

Access structure data and function members using the dot “.” operator. If you have a pointer to a structure object then use the short hand member access “->” operator. It is called the short hand operator because using it lets the compiler handle pointer dereferencing operations for you. The alternative to the “->” operator is to use the “.” operator in conjunction with the “*” operator.

C++ structures have all the functionality of classes but differ in their default member accessibility. The default member accessibility of structures is public, whereas the default member accessibility for classes is private. The primary difference between structures and classes lies in the way you think about programming.

A new way of programming requires a new way of thinking which, in turn, requires a new vocabulary. From now on you will speak in object speak — do I make myself clear? Right! Now, go forth and do all the exercises. I will see you in chapter 11.



 < 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