Engineering Science 1036A/B Lecture Notes - Lecture 7: Null Pointer, Compile Time, Ampersand

91 views16 pages

Document Summary

In general, it contains the address of an existing variable. A pointer variable is declared with asterisk (*) sign followed by the name of the variable int *ptr; The asterisk is known as the pointer operator. If an already declared pointer variable uses the * sign in front of it, the * sign is called a indirection or dereferencing operator. There are two general forms of declaring a pointer: Before using any pointer variable, it has to be initialized: With the address of existing variable (which has been declared) using address of (&) operator (aka reference operator) With the address of another existing pointer variable. Assigning null or 0 to a pointer indicates that it is not pointing anywhere. C++ only checks the contents of a pointer if it is != 0. The address-of operator & in front of any variable produces the address of that variable.

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