C Tutorial Rob Jagnow Overview Pointers Arrays and
C++ Tutorial Rob Jagnow
Overview • • • Pointers Arrays and strings Parameter passing Class basics Constructors & destructors Class Hierarchy Virtual Functions Coding tips Advanced topics
Pointers int *int. Ptr; Create a pointer int. Ptr = new int; Allocate memory *int. Ptr = 6837; Set value at given address 6837 *int. Ptr 0 x 0050 delete int. Ptr; Deallocate memory int other. Val = 5; int. Ptr = &other. Val; Change int. Ptr to point to a new location *int. Ptr 5 0 x 0054 other. Val &other. Val
Arrays Stack allocation int. Array[10]; int. Array[0] = 6837; Heap allocation int *int. Array; int. Array = new int[10]; int. Array[0] = 6837; . . . delete[] int. Array;
Strings A string in C++ is an array of characters char my. String[20]; strcpy(my. String, "Hello World"); Strings are terminated with the NULL or '