Can copy constructor admit an object of the same class , C/C++ Programming

Can copy constructor admit an object of the same class as parameter, rather than reference of the object?

 

Posted Date: 3/15/2013 4:04:42 AM | Location : United States





A: No. this is specified in the definition of the copy constructor itself. It must generate an error if a programmer specifies a copy constructor along a first argument that is an object and not a reference.

 

Posted by | Posted Date: 3/15/2013 4:06:03 AM

constructor with a single argument creates that constructor as conversion ctor and it can be utilized for type conversion.

For instance:

class Boo

{

public:

Boo ( int i );

};

Boo BooObject = 10; // assigning int 10 Boo object

 

Posted by | Posted Date: 3/15/2013 4:07:19 AM


Related Discussions:- Can copy constructor admit an object of the same class , Assignment Help, Ask Question on Can copy constructor admit an object of the same class , Get Answer, Expert's Help, Can copy constructor admit an object of the same class Discussions

Write discussion on Can copy constructor admit an object of the same class
Your posts are moderated
Related Questions
Explain structured programming The principal idea behind structured programming was as easy as the idea of "divide and conquer." A computer program could be regarded as having

Write a program consisting of two functions (plus main). The first function should read in a number and then pass this back to main. This value should then be passed into a secon

In this assignment the main has been written for you in the file phone_book_main.cpp. You will also notice that a class called Person has been declared as having several prototypes

write a promgram using object oriented peramid


Scope Rules and Storage Classes The storage class verifies the life of a variable in terms of its duration or its scope. There are four storage classes : automatic static

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

Write a C# program to compute the Net Pay for employees. The program is to have a Main method and two user-defined methods. The Main method is to input the employee's name (string)


Project Description: I want an app that the user can download it from the play store and use it as a keyboard for texts and writing. Just like the Samsung keyboard and the arabi