oop - About C# and Inheritance -


I have a theoretical / authentic question how the legacy works in C #.

We say that I have a model for some auto, so I have some common methods that all auto should be applied and a pilot should know. In code-words it should be an interface:

  interface automobile {void speedup (); Zero break (); Zero carrier (); Now, all types of cars should have some general technical implementation, which a pilot can work on them, let's get the property fuel level at this point, this point. But I still do not want to know how a car rises or breaks, so I must have written:  
  abstract class car: automobile {int fuel level; // for example .... public abstract zero speed (); Public essence zero segment (); Public essence void (); }   

Now I want to model Ferrari, therefore:

  class Ferrari: car {public zero speed () {...} public zero Break () {...} public void steer () {...}}   

Now, this code should work in Java (changing some syntax), but not in C # It will say:

  Error 1 'Ferrari' inherited intangible member 'Car.speedup ()' does not apply 'Error 1' Ferrari 'inherited member' car. Brake '(error) 1' Ferrari 'inherited intangible member does not apply to' Car.steer () '  

Why? How should I fix this problem?

You covered override below the abstracts definitions Public override void break () {} Public override steer () {}} Pre>

In addition, you are setting - Ferrari class will satisfy your interface, even if methods are to be derived. In addition, naming in C # is slightly different:

  • Prefix interface with I , IAutomobile .
  • Caption capital on methods: speedp () , break () , steer () .

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

ruby on rails - Convert a Activerecord result with has_one associations into a single hash per record -

javascript - Read complete data from stream from onMessage -