#include <iostream>
using namespace std;
class ClassA
{
const int a;
int b, c;
public:
ClassA(int x, int y):a(10)
{
b = x;
c = y;
}
ClassA():a(10)
{
}
void print()
{
cout << a << endl;
}
};
int main()
{
ClassA objA(10, 20);
ClassA objB;
objB = objA;
objB.print();
return 0;
}
compiler doesn't create copy assignment operator in the following cases:
- Class has a nonstatic data member of a const type or a reference type.
- Class has a nonstatic data member of a type which has an inaccessible copy assignment operator.
- Class is derived from a base class with an inaccessible copy assignment operator.
In the above cases i understood the case 1 with above example. but i am not getting case 2 and case 3 so please help me to understand with some example.