class Example has operator+= overloads.
Example Class keeps a private vector of std::vector<X*> type that it updates with several functions and operator overloads.
X is a Class that takes have constructor (not explicit) that takes int.
Example& operator+=(X* x);
Example& operator+=(X& x);
So all this works as expected. But What I want to do is.
X* x1 = new X(1);
X* x2 = new X(2);
X x4 = 4;
ex += x1;
ex += x2;
ex += x3;
ex += x4;
But it requires signature to be
But I am storing non-const pointers in the vector.
Example& operator+=(const X& x);
So What I did is I const_cast<X*>(x) it in operator+=(const X&)
Now Is that a design flaw ??
cause I am not maintaining the constness.
actually I dont use const_cast much thats why I am asking is what I am doing assumed as bad style of coding ??