Summary

 < Day Day Up > 



Perplexed One gathered his notes and walked to the front of the class. C++ Man took a seat in the front row and listened attentively as Perplexed One reviewed what he had learned.

“An object is a region of memory. An object can be a fundamental data type like a character or integer, or a complex user-defined type. An object can be created in three ways: 1) by definition, 2) by using the new or new[] operator, or 3) as required by the compiler.”

“All objects in memory can be accessed via a memory address. To determine the memory address of an object use the & operator.”

“A pointer is a variable that holds a memory address. Because a pointer is a variable, the address it contains can be changed, causing it to point to something else. Use the asterisk to declare a pointer and the asterisk to access the object a pointer points to. This is also referred to as dereferencing the pointer.”

“Dynamic object allocation allows programs to create objects at program runtime. Dynamically allocated objects are created on the application heap. Use the new operator to create dynamic objects, and don’t forget to deallocate objects when you no longer need them with the delete operator. Constructors can be used during dynamic object allocation to initialize objects in memory.”

“References differ from pointers in several ways. References must be initialized when they are declared because they are not variables. A reference is considered another name for a particular object. Use the & to declare references. The cool thing about references is that they don’t need to be dereferenced.”



 < 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