We have two following codes:
First:
class base
{
public:
static void nothing()
{
std::cout << "Nothing!" << std::endl;
}
};
class derived : public base
{
public:
static void nothing(int a)
{
std::cout << "Nothing with " << a << std::endl;
}
static void nothing(double b)
{
std::cout << "Nothing with " << b << std::endl;
}
//using base::nothing;
};
int main()
{
derived::nothing();
return 0;
}
and the second one:
class base
{
public:
static void nothing()
{
std::cout << "Nothing!" << std::endl;
}
};
class derived : public base
{
public:
/*static void nothing(int a)
{
std::cout << "Nothing with " << a << std::endl;
}
static void nothing(double b)
{
std::cout << "Nothing with " << b << std::endl;
}
*/
//using base::nothing;
};
int main()
{
derived::nothing();
return 0;
}
Question, why we cannot compile the first code ? The compiler is not able to find the inherited static method from base class, but sees only the methods from the derived class!
To compile the first example, we need to introduce the base::nothing name by 'using' declaration.
Could someone tell me why ? Why the declaration of a static 'nothing' method in the derived class, stops the compiler from seeing the inherited static methods from the base class ?