CS 162 Lecture Notes - Lecture 11: Operand, Local Variable

19 views3 pages
CS 162 Lecture 11 Big 3 Activity
Constructor
o Prototype:
ClassName();
ClassName(w/params);
o Job:
Build the object
o When is it called?
Default is called when object is declared if no parameters are given.
Nondefault is called if parameters are given
o Default behavior if not defined
Will declare all variables with garbage values, will not set up pointers
o Reminders
If any constructor is defined then the compiler will not provide one, even
if a default constructor is not defined
Copy Constructor
o Prototype
ClassName(const ClassName&);
o Job
Copies the contents of the passed in object to the destination object.
o When is it called?
Pass by value
Return value
When initializing an object with this constructor
o Default behavior if not defined
Shallow copy, will only copy over the values stored in each variable
o Reminders
Works with objects that can be assumed to be unitialized
Assignment Operator Overload
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows page 1 of the document.
Unlock all 3 pages and 3 million more documents.

Already have an account? Log in

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