What is the correct way to explicitly use a casting operator in a derived class?

StackOverflow https://stackoverflow.com/questions/22688795

  •  22-06-2023
  •  | 
  •  

Pergunta

This works fine, Derive automatically gets access to Base's operators

class Base
{
public:
 operator const SomeType &() const {...}
...
};

class Derive : public Base
{
...
};

But I need to add another casting operator to Base, which will hide the superclass operator. However when I try to use using to resolve this, before adding any new methods, the conversion no longer works at compile-time.

class Derive : public Base
{
public:
  using Base::operator const SomeType &;
...
};

What is the problem here?

Foi útil?

Solução

As mentioned in comments, what I was trying to do is correct. Problems were elsewhere in the code.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top