The Gateway to Computer Science Excellence
+4 votes

What is the right way to declare a copy constructor of a class if the name of the class is MyClass?

  1. MyClass (constant MyClass * arg)
  2. MyClass (constant MyClass & arg)
  3. MyClass (MyClass arg)
  4. MyClass (MyClass * arg)
in Object Oriented Programming by Boss (30.7k points) | 2.1k views

2 Answers

+5 votes
Best answer
it should be B (with a const keyword instead of constant )as reference of arg is passed in copy constructor
by Boss (49.3k points)
selected by
@sanjay :is there any book of Java that contain conceptual questions of Java.

Like test your c skill for c language
+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)
by (79 points)
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,291 answers
104,889 users