I often have this situation
class OrientedPoint
{
private:
Point P;
Vector N;
Color C;
bool valid;
public:
//////////// Constructors //////////
OrientedPoint() {}
OrientedPoint(const Point &Coord);
OrientedPoint(const Point &Coord, const Vector &Normal);
OrientedPoint(const Point &Coord, const Color &C);
OrientedPoint(const Point &Coord, const Vector &Normal, const Color &C);
where there are many, many constructors to initialize the class when different quantities are available at the time of construction. What I want to do is always set valid to false, without having to say "valid = false" in every constructor, or putting valid(false) in each constructor's initialization list. The idea is that since this code is very fluid, I don't want to change the same thing in 10 places. Is there anyway to do something that would be like
class OrientedPoint
{
private:
Point P;
Vector N;
Color C;
bool valid = false; //always init this variable to a certain value!
All ideas welcome!
Thanks,
Dave