Static member function overides inherited function with different arguments?

I cannot figure out why the following is happening. Maybe someone can inform me and hopefully point out a way around it.

I have a base class, call it Indexed, and a derived class, call it A. Indexed has a function GetIndex(), and A has a static function GetIndex(char * s). The static function of A causes the inherited function GetIndex() to not be recognized even though the two have different arguments.

1
2
3
4
5
6
7
8
9
class Indexed {
public:
  int GetIndex();
};

class A : public Indexed {
public:
  static int GetIndex(char * c);
};


I get the following error:

1
2
error: no matching function for call to 'A::GetIndex()'
note: candidates are: static int A::GetIndex(char*)
You appear to have called A::GetIndex(), where as you should use A::GetIndex(str). The compiler is not confused.
Sorry, I should have explained better.

I call both A::GetIndex() and A::GetIndex(str) in the code. But the compiler no longer recognizes the call the A::GetIndex() once static int A::GetIndex(str) is defined.
OK. I've solved my own problem. I hadn't realized that creating a new function with a different signature will hide the base-class's function.
Topic archived. No new replies allowed.