3140 MIDTERM Flashcards
What does specifying a function as “inline” do?
The function will (probably) be expanded in the line that it is called
Why use inline?
It lowers the runtime overhead of calling a function
Will a function specified as inline always be evaluated inline?
No, the compiler may choose not to
What restrictions are imposed on constexpr functions?
- Return type and parameter types must be a literal type
- It must only have one return statement
What does the compiler do with constexpr?
Replace the function with the value if able
Where should inline and constexpr functions be defined?
Header files
What are the 2 steps the compiler takes with classes?
- Declarations
- Function bodies
Do constructors have a return type?
No
Can constructors be declares as const?
No
Can constructors write to const objects?
Yes, during construction
What is a default constructor called in C++?
Synthesized Default Constructor
What was the first programming paradigm?
Imperative Programming
What are records in OOP?
Structures used to group related data together
What was the first OO language?
Simula
What are the three pillars of OOP?
- Encapsulation (Abstraction)
- Inheritance
- Polymorphism
What are the two parts of encapsulation?
- Abstraction
- Data Hiding
What are the 4 access specifiers?
- Public
- Private
- Protected
- Friend
What is RAII?
Resource Allocation Is Initialization
What is the best practice for initializing an instance of a class?
Name n{ };