4 votes 4 votes What is the right way to declare a copy constructor of a class if the name of the class is MyClass? MyClass (constant MyClass * arg) MyClass (constant MyClass & arg) MyClass (MyClass arg) MyClass (MyClass * arg) Object Oriented Programming isro2013 copy-constructor non-gate + – makhdoom ghaya asked May 13, 2016 makhdoom ghaya 8.2k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 5 votes 5 votes it should be B (with a const keyword instead of constant )as reference of arg is passed in copy constructor Sanjay Sharma answered May 13, 2016 • selected Jun 8, 2016 by Arjun Sanjay Sharma comment Share Follow See all 2 Comments See all 2 2 Comments reply Sourabh Kumar commented Jun 16, 2016 reply Follow Share @sanjay :is there any book of Java that contain conceptual questions of Java. Like test your c skill for c language 2 votes 2 votes RISHIKESH MAURYA commented Jun 27, 2016 reply Follow Share http://stackoverflow.com/questions/3278625/when-do-we-have-to-use-copy-constructors 0 votes 0 votes Please log in or register to add a comment.
2 votes 2 votes In the question, a particular language is not mentioned so option B and C both are correct. In Java copy constructor: MyClass(MyClass arg) But In C++ it is : MyClass (constant MyClass & arg) Bhavneet 01 answered May 3, 2017 Bhavneet 01 comment Share Follow See all 0 reply Please log in or register to add a comment.