This is what I read about it.
virtual base class becomes common direct base for the derived class
So my question is exactly what does this mean.
What I believe it means.
class A
{
protected:
int a;
public:
virtual int get_a();
A(void);
~A(void);
};
With an inherited class of B
class B : public virtual B
{
protected:
int b;
public:
virtual int get_b();
B(void);
~B(void);
};
My assumption is that when a program is created in C++ there is a batch of memory where the functions for each class are held. Whenever I do something like A.get_a() it grabs the function from that pool of memory and processes it like you would expect a function to do so. If I do a non-virtual inheritance my assumption is that it grabs get_a() function from the pool of memory set for class A. However, if it is virtually inherited than a copy of get_a() exists in both the pool memory for class A function and class B functions if directly inherited without modification as shown.
I think this is wrong because I don't see the utility of it unless virtual can be applied in some way I'm not aware. Like maybe a virtual static member so each virtual inherited member gets it's own copy because they might need to be slightly different.