Podcast
Questions and Answers
What is the purpose of virtual functions in C++?
What is the purpose of virtual functions in C++?
- To allow a function in a base class to be overridden in a derived class (correct)
- To restrict access to a function in a derived class
- To enable direct instantiation of a function in a derived class
- To prevent a function from being overridden in a derived class
What is the difference between aggregation and composition in C++?
What is the difference between aggregation and composition in C++?
- Aggregation represents a 'has-a' relationship, while composition represents a 'part-of' relationship (correct)
- Aggregation is a single-class concept, while composition involves multiple classes
- Aggregation allows for dynamic binding, while composition allows for static binding
- Aggregation is used for inheritance, while composition is used for polymorphism
What is the purpose of operator overloading in C++?
What is the purpose of operator overloading in C++?
- To limit the functionality of operators in derived classes
- To enable direct access to memory locations using operators
- To redefine the way operators work for user-defined types (correct)
- To restrict the use of operators for built-in types