Connecting Tech Pros Worldwide Forums | Help | Site Map

Initializing member variable array?

BCC
Guest
 
Posts: n/a
#1: Jul 23 '05
If I have a class with the following member var:
std::string* m_array;

Is there a way to initialize it in the constructor using new or anything
else in this fashion:
m_array = new std::string {"string1", "string2", "string3" };

I know I can do:
char* array[] = {"string1", "string2", "string3"};

Is there any way to do something similar with a member var?

Thanks,
B

Victor Bazarov
Guest
 
Posts: n/a
#2: Jul 23 '05

re: Initializing member variable array?


BCC wrote:[color=blue]
> If I have a class with the following member var:
> std::string* m_array;
>
> Is there a way to initialize it in the constructor using new or anything
> else in this fashion:
> m_array = new std::string {"string1", "string2", "string3" };[/color]

No.
[color=blue]
> I know I can do:
> char* array[] = {"string1", "string2", "string3"};
>
> Is there any way to do something similar with a member var?[/color]

No.

V
Closed Thread