COM SCI 32 Lecture 1: Lec 1, 2 - Pointers, Class Composition, Dynamic Memory Allocation
Document Summary
Cs 32 - lec 1, 2 - pointers, class composition, dynamic memory allocation. Pointers int main() int var = 1234; int *ptr; ptr = &var; //remember to set the value of a pointer variable before using the * operator cout << *ptr; // print the value stored in that address. *ptr = 5; //set 5 at the address ptr void swap (int *pa, int *pb) int temp; temp = *pa; Use c++ structs to define a new type to use one variable to store a student"s name, id, and. Example of a . h student. h struct student string name; //specify the members that our new type contains int id; float gpa; Student t, u; t. name = carey ; t. id = 113353948; t. gpa = 3. 99; u. name = david ; u. gpa = 1. 12; A constructor that inializes a csprof that has name and age (age should be default 39): class csprof public: