Sie sind auf Seite 1von 2

C++ PRIMER(Notes TB Ch.

0)

---------------
Function main
---------------
- identifies the start of the program
- always in format int main(){}
- int tells the compiler that the main function returns an int value to the OS.
- returns a value of 0 "i.e. at end, 'return 0'"
- 0 return value indicates normal completion.
- nonzero return value signifies an error in the main

*****************************************
*P.2. Preprocessor Directives and Macros*
*****************************************

****************************************
*P.5. Objects, Pointers, and References*
****************************************
- C++ is unique in that objects can be from built-in types(e.g. primitive data
types) or a class type.
- in java, objects are ALWAYS instances of classes and primitive data types
are not objects.
- an object is an area of computer's memory containing data of a kind determined by
its type.
- objects can be declared inside other objects.
- class-type objects are often built from other classes and primitive data
objects.

------------------
Object Lifetimes
------------------
- objects have a lifetime that is associated with their use
- after objects have been used, keeping them around would be wasting memory.
- Creation: happens when the object is declared.
- can supply optional initialization values in declaration statement.
- upon object declaration execution, the computer allocates space for the
object
and its optional initialization value
- global objects declared outside the scope of the main
- therefore created upon declaration, before the main executes
- not often recommended bc they waste space
- local objects are either declared within a function or declared within a
class.

OBJECT DECLARATION

Form:
type-name name; //e.g. int i;
type-name name = intitial-value; //e.g. string s = "hello";
type-name name(parameter-list); //e.g. point p(x,y);

- the object name is declared in order to reference the specific type-name.

- Destruction:
- Global objects are destroyed after the main function executes.
- objects declared within a function are destroyed when that function is
exited.
- objects declared within a class are destroyed when the class(an object
itself) containing them is destroyed.

----------
Pointers
----------

-----------------------------
Dynamically Created Objects
-----------------------------

Das könnte Ihnen auch gefallen