I have a vector 3D class

```
class Vector3D{
    public: float x; float y; float z;
    //some functions, e.g. operator+ - * / 
    //some 3D-specific function
};

```

and a vector N-D class. 

```
template<int constSize> class VecFloatFix{
    float database[constSize];
    //some functions, e.g. operator+ - * / 
};

```

I noticed that there is code-duplication between two classes, so I think I should make `Vector3D` derived from `VecFloatFix<3>` :-

```
class Vector3D : public VecFloatFix<3>{
    //some 3D-specific function
};

```

Everything seems to be good, except that there are a lot of user code access `Vector3D::x,y,z` directly.

Is it possible to make `Vector3D` derived from `VecFloatFix<3>` while not break user's code?

My best guess is around :-

```
template<int constSize> class VecFloatFix{
    union{
        float database[constSize];
        float x,y,z;  ?????  sound like a hack
    }
    //some functions, e.g. operator+ - * / 
};

```

**Edit:** Hardcoding `x,y,z` into `VecFloatFix` is unsustainable.  

If I have a new class `Vector2D` that derived from `VecFloatFix<2>`, `Vector2D::z` will compile fine (dangerous).