Pepelee
Pepelee

Reputation: 453

Template multiple inheritance ambigious symbol error

i got a real problem, which can be summarized like this:

template <typename BaseType>
class TemplateClass
{
public:
    template <typename BaseTypee, unsigned PrefixID>
    static void deleteType(unsigned int ObjID)
    {

    }
};

class ParentClass:
    public TemplateClass<ParentClass>
{
};

class ChildClass:
      public ParentClass, public TemplateClass<ChildClass>
{   
    using TemplateClass<ChildClass>::deleteType; //Ambigious Symbol Compiler-Error

};

I call the function deleteType like this:

TemplateClass<ChildClass>::deleteType<ChildClass, ChildType>(ChildType);

I want to call the function deleteType in the ChildClass Class, but without any declaration the function will be called in ParentClass.

How can i get rid of the ambigious symbol error in the using-phrase? Can achieve my task with a different approach?

FYI: Originally, i tried calling the function with (nothing changes)

ChildClass::deleteType<ChildClass, ChildType>(ChildType);

funny thing: it still compiles although has a red underline. If i debug, the Template will be still called in ParentClass, at compilation is no warning nor error thrown..

Upvotes: 0

Views: 52

Answers (1)

Johan Boul&#233;
Johan Boul&#233;

Reputation: 2090

Put your using statement in a public: section :

template <typename BaseType>
class TemplateClass
{
public:
    template <typename BaseTypee, unsigned PrefixID>
    static void deleteType(unsigned int ObjID)
    {
    }
};

class ParentClass:
    public TemplateClass<ParentClass>
{
};

class ChildClass:
      public ParentClass, public TemplateClass<ChildClass>
{   
public:
    using TemplateClass<ChildClass>::deleteType;
};

int main() {
    ChildClass::deleteType<void, 0>(0);
}

Upvotes: 1

Related Questions