Skip to content
Related Articles

Related Articles

Improve Article

C++ | Constructors | Question 17

  • Last Updated : 28 Jun, 2021
Geek Week

using namespace std;
class Test
   Test(Test &t) { }
   Test()        { }
Test fun()
    cout << "fun() Called\n";
    Test t;
    return t;
int main()
    Test t1;
    Test t2 = fun();
    return 0;

(A) fun() Called
(B) Empty Output
(C) Compiler Error: Because copy constructor argument is non-const

Answer: (C)

Explanation: See following for details:

Why copy constructor argument should be const in C++?

Quiz of this Question

Take a step-up from those “Hello World” programs. Learn to implement data structures like Heap, Stacks, Linked List and many more! Check out our Data Structures in C course to start learning today.
My Personal Notes arrow_drop_up
Recommended Articles
Page :