Game Development Reference
In-Depth Information
Dynamic memory allocation : This happens when the memory allocation for
a variable value is manually assigned using the new and delete keywords.
Garbage collection : This is a very useful operation that we already men-
tioned when discussing the basics of iOS game development in Chapter 1 ,
Operation Systems - Mobile and Otherwise . It is a way to automatically man-
age memory allocation that relieves the programmer from doing it manually
and is performed by dedicated software such as the very popular Boehm-
Demers-Weiser
garbage
collector
( http://en.wikipedia.org/wiki/
Boehm_garbage_collector ) .
Memory management is one of the most important aspects of the C++ programming
language. It is both a welcome feature, as it gives full control to programmers over
the execution of a piece of code, and a blamed characteristic, for it requires ex-
tra work of programmers when compared to other languages such as Java or Perl,
which don't require any memory management at all. It is a classical situation of bal-
ancing the pros and cons of control over efficiency!
Objects
C++ is an object-oriented programming language that uses classes. Classes are
definitions of types of data structures and the functions that operate on those data.
Thanks to the use of classes, C++ allows abstraction, encapsulation, inheritance,
and polymorphism.
We already mentioned that abstraction allows a piece of code to work independently
of the hardware it runs on.
Encapsulation means that all data are contained and hidden in a class, and are only
accessible to members of that class, so that classes work as some kind of black
boxes. The advantage of this technique is that it prevents human errors, since the
class can't be accidentally modified or corrupted while writing a piece of code.
Inheritance means that when a new class is declared, which extends a pre-existing
class, it automatically gets all the attributes and behaviors that were available to the
class it extends. Inheritance saves development time and efforts. For example, when
programming game objects for your application, the programmer can create a gen-
eral class which defines the basic properties common to each game object, and then
extend other classes from that which will share the same so-called members.
Search WWH ::




Custom Search