I've a class with some overloaded constructor and no default constructor. The overloaded constructor essentially do the same things but differ on the type
of params provided. Let's say I've a class as follows -
struct info {
int one; // must be filled
int two; // can be empty
int three; // can be empty
}
class A {
int a;
double b;
float c;
info I;
public:
A(a,b,c,one) :
a(a),
b(b),
c(c)
{
// some processing
I.one = one;
// some other processing
....
}
A(a,b,c,i) :
a(a),
b(b),
c(c),
I(i)
{
// some processing
// some other processing
....
}
}
The processing and some processing part is repeating and is slightly dependent on certain paths which are frequently edited, forcing us to do same and same changes to both places.
Can this be reduced to same constructor in some way? I was hoping to do something with constructor delegation, but wasn't able to think of a clever way to do this :/