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.
Code:
Example& operator+=(X* x);
Example& operator+=(X& x);
X is a Class that takes have constructor (not explicit) that takes int.
Code:
X* x1 = new X(1);
X* x2 = new X(2);
X x3(3);
X x4 = 4;
Example ex;
ex += x1;
ex += x2;
ex += x3;
ex += x4;
So all this works as expected. But What I want to do is.
But it requires signature to be
Code:
Example& operator+=(const X& x);
But I am storing non-const pointers in the vector.
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 ??