Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > copy constructor compilation error

Reply
Thread Tools

copy constructor compilation error

 
 
mnvasanth mnvasanth is offline
Junior Member
Join Date: Mar 2007
Posts: 1
 
      03-23-2007
Hi , please give your comment for compiler error in the following code

#include <iostream>
using namespace std;

class CA
{
public:
CA(int a=0)
{
cout<<"in constructor"<<endl;
}
~CA()
{
cout<<"in Destructor"<<endl;
}
CA(CA&)
{
cout<<"in copy"<<endl;
}

};

int main()
{

CA a = CA(2);

}

The GCC compiler gives the following error

../main.cpp: In function `int main()':
../main.cpp:27: error: no matching function for call to `CA::CA(CA)'
../main.cpp:17: note: candidates are: CA::CA(CA&)
../main.cpp:9: note: CA::CA(int)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
template copy constructor vs normal copy constructor cinsk C++ 35 10-10-2010 11:14 PM
Compilation error with seperate compilation C__chp C++ 4 02-15-2008 03:57 PM
A constructor calling another constructor (default constructor)? Generic Usenet Account C++ 10 11-28-2007 04:12 AM
Calling base class constructor from derived class Copy constructor ali C++ 4 03-05-2007 09:15 AM
Copy constructor hides default constructor Aire C++ 3 01-25-2004 05:47 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57