Boost logo

Boost :

From: Paul Giaccone (paulg_at_[hidden])
Date: 2007-01-22 12:02:55


Ben FrantzDale wrote:
> Is there a generic way to to initialize to zero an object representing a
> point in a linear space? I know the base types can be constructed like
> int foo(0);
> or
> double bar(0);
> but but if I have a three-vector class, I don't want to give it
> Vector::Vector(double);
> because Vector(2) makes no sense. (Should Vector(2) make the Vector (2, 0,
> 0) or the Vector (2, 2, 2)?) I also would rather have Vector() create three
>

This is really a C++ question rather than a Boost one, if I have
understood it correctly.

I usually use an unparameterised constructor for this, and, indeed,
there is one in the code I am working on right now:

Vector::Vector(void) : x(0.0), y(0.0), z(0,0)
{
    //any other stuff here
}

Does this do what you want?

Paul


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk