Dominance (C++)

From Seo Wiki - Search Engine Optimization and Programming Languages

Jump to: navigation, search

In the C++ programming language, dominance implies a specific behaviour of symbol disambiguation in virtual inheritance. Consider the following example:

class Parent
{
public:
    void function();
};
 
class Child1 : public virtual Parent
{
public:
    void function();
};
 
class Child2 : public virtual Parent
{
};
 
class Grandchild : public Child1, public Child2
{
public:
   Grandchild()
    {
        function();
    }
};

In the Grandchild call to function(), Child1::function is implied, because Child1 is derived from Parent and thus Child1::function "dominates" Parent::function.

See also


Personal tools

Served in 0.094 secs.