Next: Declaring a global variable
Up: C++/C
Previous: Static object initialization order
If the derived class doesn't define a static method with same name as the one defined in the base class,
use can access the static method by Driver::foo();
But once the derived class has a method with same name, even the signature is different;
the new defined static method will hide the one defined in the base class;
For example:
class Foo
{
public:
static void foo()
{
printf("foo");
}
};
class Bar : public Foo
{
public:
static void foo(int)
{
printf("bar");
}
};
int main(int argc, char* argv[])
{
//compilier complian can't find the foo() method
Bar::foo();
}
Wei Lu
2007-11-06