The return value of the following code is

Class1& test(Class1 obj)
{
Class1 *ptr = new Class1();
.........
return ptr;
}

Options
- object of Class1
- reference to ptr
- reference of Class1
- object pointed by ptr


CORRECT ANSWER : reference to ptr

Discussion Board
C++ - Pointer

The return value of the following code is reference to ptr (pointer).

Prajakta Pandit 01-25-2017 03:57 AM

CSE

To return reference it needs return *ptr

Ankit 01-9-2014 11:25 PM

Needs dereferencing

"return ptr" should be "return *ptr;"

Alexandre Thibodeau 12-15-2013 12:14 PM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement