class MyClass {
public:
CStringArray numbers[10] =
{"-178","8","382","-262","34","8374","-16","736","54","124"};
//...
};
The compiler for VC++ doesn't like it. In fact it doesn't like array
initialization at all. Here's an example for a built-in type that VC++
doesn't like:
class MyClass {
public:
double nums[3] = {3.4,5.2,8.9};
//...
};
I don't seem to find an answer to this question in any of my C++ books
[Stroustrup, Kruglinski, Prosise, Meyers,etc.]. It would be very convenient
to do it this way. If it can't be done this way, what other ways are there?
Any help would be appreciated.
Regards,
Bill Pate
Try initializing your array in the Class constructor instead of the definition.
class MyClass {
public:
CStringArray numbers[10];
//...
};
MyClass::MyClass()
{
numbers = {"-178","8","382","-262","34","8374","-16","736","54","124"};
}
vedprakash
Bill Pate wrote in message ...
>Is it possible to initialize a CStringArray in the definition of a class?
>Here's an example of what I want to do:
>
>class MyClass {
>public:
> CStringArray numbers[10] =
>{"-178","8","382","-262","34","8374","-16","736","54","124"};