lecture three: class, object, and operator overloading Flashcards
(9 cards)
what are constructors used for?
initialize objects upon declaration
are constructors called implicitly or explicitly?
they are called implicitly when an object is initialized, but can also be called explicitly
how do you pass information to constructors?
using parameters
how can you make a class/ADT look like part of the c++ language? (instead of a.add(b) it’s a + b)
by overloading operators
are friend functions methods?
no
do friend functions get the ::?
no
all classes need a __________
default constructor
why do all classes need a default constructor?
If you declare an array of a type which does not have a default constructor, you get an error. The default constructor is called for each element of the array.