4. Engineering C++ Software Solutions Flashcards
What is a template type? Example?
A template type is a special type that can take on different types when the type is initialized.
std::vector uses a template type and can be of type int, char, etc.
What is a “friend” declaration?
A friend declaration grants a function or another class access to private and protected member variables.
What is inheritance?
Inheritance allows a class to inherit all member functions and data from a class into a derived class.
True or false?
When a derived class is initialized, the derived class must construct the base class.
True.
When a base class is inherited, what does/doesn’t the derived class have access to?
The derived class can access public members of the base class, but not private members.
What is an initializer list and what is it used for?
An initializer list is the syntax to initialize the base class. It is used to:
- initialize a base class
- initialize the current class using another constructor
- initialize the default values of member variables