Connecting Tech Pros Worldwide Help | Site Map

Initializing member variable array?

  #1  
Old July 23rd, 2005, 05:58 AM
BCC
Guest
 
Posts: n/a
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
  #2  
Old July 23rd, 2005, 05:58 AM
Victor Bazarov
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Having problems initializing a managed array raylopez99 answers 3 January 2nd, 2007 08:55 PM
assign constant string to BYTE array Orange answers 5 July 12th, 2006 05:15 PM
Initializing a class member variable which is a reference to an array amparikh@gmail.com answers 5 March 4th, 2006 12:25 AM
Initializing 2D array in constructor alexkcha@gmail.com answers 1 November 22nd, 2005 04:09 AM