I develop in C++, and sometimes I wish I could say something like this:
class Heading : public float // this line won't compile
{
public:
Heading( float const value_ )
: float(value_) // this line won't compile
{
assert( value_ >= 0.0f );
assert( value_ <= 360.0f );
}
};
Instead, I have to do something like:
class Heading : public float
{
public:
Heading( float const value_ )
: value(value_)
{
assert( value >= 0.0f );
assert( value <= 360.0f );
}
private:
float value;
};
Are there any programming languages out there that allow you to extend value types?