Click to See Complete Forum and Search --> : How to initialize structures inside a class?


Marisa
May 17th, 1999, 02:30 AM
How do u initialize a structure inside a class e.g
class Mail
{
public:
struct VM{
char current[20];
char dtmf;
char next[20];
void (*ifptr)(int,int);
};
typedef VM VMail;
VMail Mailme[] = {
{ "qq", 'd', "ww", Function1},
{ "aa", 'w', "eee", Function2},
};
}

The compiler cannot recognize the initialization here. How do i put this part of the initialization code in the constructor?
VMail Mailme[] = {
{ "qq", 'd', "ww", Function1},
{ "aa", 'w', "eee", Function2},
};
I already tried putting it in the constructor but it still cannot work. How else can i initialize my structure?

Thanks

ric
May 17th, 1999, 04:16 AM
I do not know if this is the problem, but if I had to do this I would do it like this:

// Just declare globally
typedef struct VM{
char current[20];
char dtmf;
char next[20];
void (*ifptr)(int,int);
} VMail;

Class Mail
{
VMail mail[2];

};

void Mail::Mail()
{
mail[0].string = "Hello";
......
}