Connecting Tech Pros Worldwide Help | Site Map

Initializing member variable array?

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 04:58 AM
BCC
Guest
 
Posts: n/a
Default Initializing member variable array?

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, 04:58 AM
Victor Bazarov
Guest
 
Posts: n/a
Default 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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.