Initialize dynamic allocated data before main get error?
From: Tony Johansson (johansson.andersson_at_telia.com)
Date: 04/29/04
- Next message: Pete Lees: "Re: c# and help.chm"
- Previous message: Chris \( Val \): "Re: c# and help.chm"
- Next in thread: Chris \( Val \): "Re: Initialize dynamic allocated data before main get error?"
- Reply: Chris \( Val \): "Re: Initialize dynamic allocated data before main get error?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 29 Apr 2004 08:58:38 GMT
Hello Experts!!
Here an easy question. If I initialize the dynamic allocated q global which
means before main I get a lot of compilation error.
I just want to know why I can't do that.
I can assign an integer to tal and I can assign the string "this is a test"
to the name field before the main without any problem.
If I instead move the initialize of q to the main part it works.
int tal = 5;
char namn[] = "this is a test";
int *q = new int[5];
q[0] = 0;
q[1] = 1;
q[2] = 2;
q[3] = 3;
q[4] = 4;
int main()
{
return 0;
}
//Tony
- Next message: Pete Lees: "Re: c# and help.chm"
- Previous message: Chris \( Val \): "Re: c# and help.chm"
- Next in thread: Chris \( Val \): "Re: Initialize dynamic allocated data before main get error?"
- Reply: Chris \( Val \): "Re: Initialize dynamic allocated data before main get error?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|