What are multiple inheritances (virtual inheritance)? What are its advantages and disadvantages?
Answer / Aakash Bajpai
Multiple inheritance in C++ refers to a class that inherits from more than one base class. Virtual inheritance is a type of multiple inheritance where the same base class appears multiple times within a hierarchy but with a `virtual` specifier, ensuring that there will be only one object of the common base class shared by all derived classes. Advantages include code reuse and easier implementation of some design patterns; disadvantages include increased complexity and the diamond problem (ambiguity when deriving from multiple bases with the same member).
| Is This Answer Correct ? | 0 Yes | 0 No |
How can you prevent accessing of the private parts of my class by other programmers (violating encapsulation)?
Implement strcmp
What are virtual functions and what is its use?
plz send me National informatics center paper pattern
A milk carton can hold 3.78 litres of milk. Each morning, a dairy farm ships cartons of milk to a local grocery store. The cost of producing one litre of milk is $0.38, and the profit of each carton of milk is $0.27. Write a C++ program that prompts the user to enter the total amount of milk produced in the morning. Then display the number of milk cartons needed to hold milk, the cost of producing milk, and the profit for producing milk.
What is virtual destructor? What is its use?
What is the use of endl in c++ give an example?
Why was c++ made?
What happens if a pointer is deleted twice?
What are the two types of comments, and how do they differ?
Why Pointers are not used in C++?
What are virtual functions in c++?