|
-
December 27th, 2005, 10:19 AM
#1
initializing an array in a class object
I am trying to initialize an array (julian days by month) when an instance of a class object is created. I have no idea how to do this. have tried the standard approach of initialization as done in global or local variable declarations within the class:
class myclass
{
long int juliandays[11] = {31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
public
myclass();
}
and that gives me a compiler error. Prefixing the variable with static (since only one copy is really needed) gave the same error.
The only way I have been able to initialize that variable is by brute force entry of each element in the constructor function. There MUST be a better way ! (I'd hate to have to initialize an array of 100 elements in that manner.)
Does anyone know the correct syntax to accomplish this seemingly trivial task?
Thanks,
Brian
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|