C++ | Constructors | Question 17
#include<iostream> using namespace std; class Test { public: Test(Test &t;) { } Test() { } }; Test fun() { cout << "fun() Called\n"; Test t; return t; } int main() { Test t1; Test t2 = fun(); return 0; } |
chevron_right
filter_none
(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
Recommended Posts:
- C++ | Constructors | Question 15
- C++ | Constructors | Question 5
- C++ | Constructors | Question 4
- C++ | Constructors | Question 6
- C++ | Constructors | Question 7
- C++ | Constructors | Question 8
- C++ | Constructors | Question 9
- C++ | Constructors | Question 13
- C++ | Constructors | Question 12
- C++ | Constructors | Question 17
- C++ | Constructors | Question 10
- C++ | Constructors | Question 3
- C++ | Constructors | Question 14
- C++ | Constructors | Question 16
- C++ | Constructors | Question 1



