copy constructor compilation error

Joined
Mar 23, 2007
Messages
1
Reaction score
0
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top