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)
#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)