Commvault Written Test Qs.(Technical Aptitude) :: OOPS Concepts - Discussion
Home > Freshers Archives > Commvault Placement Questions & Answers > MCQs Questions Discussion
10 / 40
Choose the correct option.
What is the signature of the assignment operator in C++, if chain of assignments need to be performed for an object of class test?
Atest & operator = (const test&);
Bvoid & operator =(const test&);
Ctest & operator = ();
Dvoid & operator = (const test);
Answer: Option (Login/Signup)
Show Explanation
Asked In ::
TRICK
test & operator = (const test&) { ... }
This is the standard way to overload assignment operator in c++ by reference.
Then, t1 = t2 = t3 (t1, t2 and t3 are instances of class test ) calls above assignement operator twice.
in other hand, returning void will prevent users from 'assignment chaining' i.e t1 = t2 = t3.
This is the standard way to overload assignment operator in c++ by reference.
Then, t1 = t2 = t3 (t1, t2 and t3 are instances of class test ) calls above assignement operator twice.
in other hand, returning void will prevent users from 'assignment chaining' i.e t1 = t2 = t3.
Read Full Answer
Report Error
Please Login First Click Here