The following C++ code i think is correct, but produce some warnings when compiled with "-Woverloaded-virtual", is the warning bogus or there is a real problem with this code?
If that is a bogus warning what can i do to avoid it, define all the exception virtual variants in derived get rids of the warning but maybe is a better solution
G++ command:
g++ -c -Woverloaded-virtual test.cpp
test.cpp:22:18: warning: ‘virtual void intermediate::exception(const char*)’ was hidden [-Woverloaded-virtual]
test.cpp:32:18: warning: by ‘virtual void derived::exception()’ [-Woverloaded-virtual]
C++ code
using namespace std;
class base
{
public:
virtual void exception() = 0;
virtual void exception(const char*) = 0;
};
class intermediate : public base
{
public:
virtual void exception()
{
cerr << "unknown exception" << endl;
}
virtual void exception(const char* msg)
{
cerr << "exception: " << msg << endl;
}
};
class derived : public intermediate
{
public:
virtual void exception()
{
intermediate::exception("derived:unknown exception");
}
};