Hi,
You should get acquainted with
initializer lists[
^] as they are generalized in
C++0x.
To initialize a
C array member
in a
C++ class constructor
, (which is poor design), swap it with a default initialized one, for instance:
#include <algorithm>
class MyClass
{
float fvariable[100];
public:
MyClass()
{
float temp[100] = {0};
std::swap(fvariable, temp);
}
};
If you use a modern C++ compiler (which you should) as VC2010 or gcc 4.5 replace your
C array
by a
C++ std::array
, and it will be default initialized:
#include <array>
class MyClass
{
std::array<float, 100> fvariable;
public:
MyClass()
{}
};
cheers,
AR