Question: We have the following C++ code in a function main(): string str_a = ABCDE ; string str_b = XYZUV ; string str_c = TAMU ;

We have the following C++ code in a function main():

string str_a = "ABCDE" ;

string str_b = "XYZUV" ;

string str_c = "TAMU" ;

string * ptr1 = NULL;

string * ptr2 = &str_b ;

ptr1 = &str_a ;

ptr1 = &str_c ;

cout << *ptr1 << endl;

cout << ptr1 << endl;

cout << *ptr2 << endl;

cout << ptr2 << endl;

What would be displayed when the above code segment is executed?

(a)

NULL

{the address of str_a}

XYZUV

{the address of str_b}

(b)

{the address of str_a}

ABCDE

{the address of str_b}

(c)

ABCDE

{the address of str_a}

XYZUV

{the address of str_b}

(d)

TAMU

{the address of str_c}

XYZUV

{the address of str_b}

(e)

ABCDE

XYZUV

{the address of str_a}

{the address of str_b}

(f)

TAMU

{the address of str_c}

ABCDE

{the address of str_a}

(g) None of (a) through (f) is a correct answer.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!