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
What are compound statements? - Compound statements are made up of two or more program statements that are executed together. They may be executed with a loop. - Curly brack

big-m method operation reseach in progrmme c++..

C Program to copy the contents of a file: void main()    {   ifstream fin("input.txt");   ofstream fout("output.txt");   char ch;   while (fin)       {

Using the Constructor There are basically three ways of creating and initializing the object. The first way to call the constructor is explicitly as :

The concept of a string in C is difficult, because a string is a collection of characters stored in memory terminated by a NULL string i.e. \0. Let us consider the string Hello. Th

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Comments Comments are integral part of every program . Comments help in coding, debugging and maintaining a program . The compiler ignores them. They should be used liberally i

How do you access the values within an array? - Arrays comprise a number of elements, which depends on the size you assigned it during variable declaration. - Every element


Write a function that takes an array as the argument and returns the second largest element. Bonus (+5): Write a function that takes an array and a number n as arguments and return