I'm familiar with C++ constructors & initializers:
class Foo {
int x;
public:
Foo(int _x) : x(_x) {}
};
Foo foo1(37);
Foo foo2(104);
My question is that I have to implement a class that has a member which is a 3x6 array. How would I do something similar to the above?
class Bar {
int coeff[3][6];
public:
// what do I do for a constructor????
};
edit: for a plain array, I would do the following, I just don't know how to do it for a class:
static int myCoeffs[3][6] =
{{ 1, 2, 3, 4, 5, 6},
{ 7, 8, 9, 10, 11, 12},
{ 13, 14, 15, 16, 17, 18}};
edit 2: For various reasons (e.g. this is an embedded system w/ limitations) I need to not use Boost, so if it offers a solution I can't use it.
UPDATE: I'm not tied to an initializer. It's OK to do it in the constructor body, and it doesn't have to be inline, either. I'm just looking for a correct way to construct an instance of a class which needs an array of coefficients, without messing up pointer assignment or something.