-
initializing a static array in a class
I need to initilaize a static array of chars in my class, but my compiler
keeps giving me errors. The code is as follows:
class foobar{
public:
static char vars[2] = {'a','b'};
};
Any insight into why this won't work and how I might get around it would
be greatly appreciated.
Shayne
-
Re: initializing a static array in a class
you can't initialize an array within a class, even a static one. You can
initialize it outside the class, at the place of its definition.
int foobar:: vars[2] = {'a', 'b'};
Danny
Shayne wrote:
>
> I need to initilaize a static array of chars in my class, but my compiler
> keeps giving me errors. The code is as follows:
>
> class foobar{
> public:
> static char vars[2] = {'a','b'};
> };
>
> Any insight into why this won't work and how I might get around it would
> be greatly appreciated.
>
> Shayne
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
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|