The existing code:
typedef unsigned int uint;
Class A
{
union xReg
{
uint allX;
struct
{
uint x3 : 9;
uint x2 : 9;
uint x1 : 14;
}__attribute__((__packed__)) __attribute__((aligned(4)));
};
};
My requirement: Now, I need to derive a class from A, and and in the derived class, the bit sizes of x1, x2 and x3 has to change.
How do i do this ? Thanks for your help !
EDIT
I have a class (lets say A) with approx. 7-8 unions (each representing HW register), and around 20 (approx.) functions. Most of these functions create instances of these unions, and use the bits (x1, x2, x3 etc in my example).
Now, my requirement is to add code for a new hardware which has 95% of functionality same. The changes include the change in register bit sizes, and some functionality change. So, among 20 functions, atleast 5 functions I need to change to change the implementation. This is the reason for me to select inheritance and override these functions.
The rest 15 functions, only change is the bit size changes. So, I dont want to override these functions, but use the base class ones. But, the bit sizes of the registers (unions) should change. How do I do that?