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
for different operation multiple stack

(c) A static member function can access static member data only, static member functions and functions and data outside the class. A static member function may be called, even whil

I need plugin for amibroker using c++ Project Description: Need to prepare plugin for amibroker using c++. Should be system bound after installing. System should show based o

Implement (a part of) electronic election Scenario where following political parties are participating in election: PPP, PML and PTI.  Create a class PollingStation where it stor

push and pop operation using array draw flowcharts

The program will consist of two text fields, two buttons, and a counter label.  One text field will be input, where the user types the plain text.  The second text field will be ou

Write a c++ program to find the sum of 0.123 ? 103 and 0.456 ? 102 and write the result in three significant digits.

Declaration of Variables: Variables are declared as follows: int a; float b;   Assigning value to variables: int a = 100; Declaring and assigning is called ini

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 Program to illustrate the Call by Reference? Here is an illustration: #include . int compute_sum(int *n); int main( void) { int n=3, sum; printf("%d\n",n); /