53.2k views
2 votes
Assuming that a program has the following string object definition, which statement correctly assigns the string literal "Jane" to the string object?

string name;
name = "Jane";
string name = {Jane};
name = 'Jane';
name = Jane;

User Yoichi
by
7.6k points

1 Answer

1 vote

Answer:

name="Jane";

Step-by-step explanation:

In C++ assigning a value to a string object takes the following syntax:

String variable declaration prior to the assignment using:

string <variable-name>;

String variable assignment:

<variable-name> = "<variable-value>";

As per the question, the variable-name is 'name' and variable-value is 'Jane'. So the required assignment has the format:

string name;

name="Jane";

User Zhambulable
by
7.9k points

No related questions found

Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.