c++ - In Inheritance: Can I override base class data members? -


Assume that I have two squares like the following squares:

  class A { Public: Private: integer length; } Class B: Public Class A {Public: Private: Float Length; }  

What do I want to know: 1) Is the base category data allowed? 2) If so, is it a good practice? 3) If not, what is the best way to increase the type of data members of a class?

There is a class that meets my needs and I want to use it again. However, for the needs of my program, its data members should be of another type.

I have some books, but they all mention to override only base class member methods. Thank you in advance.

You can use normal members instead of templated members ie members override. / P>

You can also declare a variant (com) like a union.

  struct MyData {int vt; // To store the type union {long time lVal; Byte Behavior; Shortyear; Float flat valves; . . }};  

Comments