How to remove one structure element

L

Leon Pollak

Hello, all.
I have the structure
struct tStruct {
int a;
int b;
int c;
.....
};
and a lot of working code based on this structure.

Now comes the change, that makes exactly the same processing in all derived
objects, with the only exception: no element 'b' is allowed (the structure
arrives from several communication channels).

The only solution which came to me was:

template <int T> struct tStruct {
int a;
int b[T];
int c;
.....
};
which will eliminate 'b' in the case of declaration:
tStruct<0> Object;

But this mans that the existing case
tStruct<1> Object;
requires all code rewriting to change
Object.b = 1;
to the new one:
Object.b[0] = 1;

Obviously, very not desirable rework...

Is there some more elegant way to solve this?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top