static and inheritance

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hi!

I'm a correct if I say that when you have static members you can't use any
kind of inheriatance ?

//Tony
 
Tony Johansson said:
I'm a correct if I say that when you have static members you can't use any
kind of inheriatance ?

No, that's not correct. You can inherit perfectly well from a class that
contains static members. It's just that the static members will be shared
with any instances of the child class, and they cannot be overridden. But
otherwise, the class can be inherited with no problem.
 
No - having static members doesn't interfere with inheritance.
Public static members of a base class become static members of the derived
class, so static members participate in the inheritance scheme.
 
I'm a correct if I say that when you have static members you can't use any
kind of inheriatance ?

A class with static members can both be a sub class of another
class and have sub classes.

But static members can not be virtual/overridden. This makes
inheritance somewhat irrelevant for static members.

Arne
 
Back
Top