CS 162 Lecture Notes - Object Copying
CS 162 – Lecture 13 – Exam Answers and Explanations
Exam answers
o You can use assignment character with objects
o A struct is declaring the same as any other data type
▪ Can be returned in a function
o Constructors in a class need to be public to be used
o Arrow operator dereferences a pointer and works as the dot operator in one
o File output can be formatted the same as cout
o A destructor is not allowed to have any parameters
o Encapsulation is the hiding of implementation details
▪ The object does not encapsulate things, it has to do with the way the
class is set up
o In c++ data members in a class can be public or private
o A static member function does not need to be called by a specific object of the
class
o Constructors are called automatically
▪ Cannot be called with dot operator
o In a shallow copy, pointers are not followed, just location stored
o Structs are found in interface files (.h)
o Header guards prevent multiple includes of an interface file
o <> means go look somewhere else
▪ ea look loall
o classes are default private and have functionality and structs are default public
ad do’t hae futioalit
o const means the function will not change the member variables
o do not need delete in a copy constructor
▪ assumes that the object that we are copying into does not exist yet,
therefore there is nothing to delete
o constructor is automatically called when a class object is created
find more resources at oneclass.com
find more resources at oneclass.com