J
jimmij
Hi,
Please look at the code bellow
/*******************/
class ctab
{
private:
static const unsigned n=48;
public:
int tab[n];
//int tab[n]={0}; //error, but outside class is good
ctab();
};
/*******************/
I would like to initialize each element of tab to zero.
It can be done in constructor (in a loop or by memset), but the perfect
would be if I will be able to declare and initialize table like in
commented line.
So two questions:
1.Why it is imposible to do that in class, what is a reason for that?
2.What is a best way to solve my problem? In real code I have several
arrays, each has several dimensions, so loops will slow down program and
extend code. Is memset the only choice?
Thanks in advance,
Please look at the code bellow
/*******************/
class ctab
{
private:
static const unsigned n=48;
public:
int tab[n];
//int tab[n]={0}; //error, but outside class is good
ctab();
};
/*******************/
I would like to initialize each element of tab to zero.
It can be done in constructor (in a loop or by memset), but the perfect
would be if I will be able to declare and initialize table like in
commented line.
So two questions:
1.Why it is imposible to do that in class, what is a reason for that?
2.What is a best way to solve my problem? In real code I have several
arrays, each has several dimensions, so loops will slow down program and
extend code. Is memset the only choice?
Thanks in advance,