EECS 280 Lecture Notes - Lecture 3: Affix, Subtyping, Memory Management

106 views2 pages

Document Summary

Addresses: every object lives at some address in memory. No control over it: you can get the address of an object using the & operator i. e. cout << &y << endl; Pointers: we can also create objects to store addresses (pointers, to declare a pointer variable, affix * to the left of the name int *ptr = &x; Ptr = &y: there is a separate pointer type for each kind of thing you could point to, ca(cid:374)"t mix them int *ptr1 = &x; Using pointers in expressions: to take the address of an object, use the & operator. Yields a pointer: to get the object a pointer points to, use * References vs. pointers: specifying a type. & (cid:373)ea(cid:374)s it"s a refere(cid:374)ce: using as an operator in expression. * means get object at an address. & means take an address of an object: references. Kinds of objects in c+: atomic. Pointer types: arrays (homogenous) int, double, char, etc.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents