How the compilers implement the virtual inheritance?
In the following code:
class A {
public:
A(int) {}
};
class B : public virtual A {
publ
As mentioned before, it depends on the compiler implementation.
But, usually each time a programmer adds a new method, is stored in code, even if there is another method with the same id. elsewhere ("overriden" or "overloaded").
The code for each method is stored only once, so if a class inherits and uses the same method from a parent class, internally, its uses a pointer to the code, it doesn't duplicates the code.
If a parent class defines a virtual method, and if a child class overrides it, both methods are stored. Each class has something called "Virtual Method Table" where there is a table of pointers to each method.
Don't worry about performance, the compiler doesn't duplicate code for methods.