|
Boost Users : |
From: Robert Dailey (rcdailey_at_[hidden])
Date: 2007-12-10 15:33:26
I'm going to be using this float to default-initialize a construction
parameter. For example:
struct default_alpha
{
static const float value = 1.0f;
};
class foo
{
foo( float r, float g, float b, float a = default_alpha::value );
};
I'm not 100% sure if the above is legal C++. I haven't gotten to the point
to where I could test it. I suppose I could try it with integrals, but I
just haven't gotten around to it.
On Dec 10, 2007 12:21 PM, Richard Hadsell <hadsell_at_[hidden]>
wrote:
> Robert Dailey wrote:
>
> Is there a way I can define constant floats within class scope like you
> can with integral values? I was hoping boost could help in this area. For
> example:
>
> struct default_alpha
> {
> static const float value = 1.0f;
> };
>
> The above is not legal, of course. Anyone? Thanks.
>
> In .h header:
>
> struct default_alpha
> {
> static const float value;
> };
>
> In .cc source file:
>
> const float default_alpha::value = 1.0f;
>
> Is this answer too simple?
>
> --
> Dick Hadsell 914-259-6320 Fax: 914-259-6499
> Reply-to: hadsell_at_[hidden]
> Blue Sky Studios http://www.blueskystudios.com
> 44 South Broadway, White Plains, NY 10601
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net