Initializing member variable array?

B

BCC

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
 
V

Victor Bazarov

BCC said:
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" };
No.

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

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

No.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top