#include<sys/types.h>
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<string.h>
class A
{
int a_;
public:
virtual ~A(){ }
A():
a_(0)
{
}
virtual int Val()const{return a_; }
virtual A& operator =(const A& a);
virtual A& operator =(int A);
};
A& A::operator =(const A& a)
{
a_=a.Val();
return *this;
}
A& A::operator =(int A)
{
a_=A;
return *this;
}
class B: public A
{
public:
B():
A()
{
}
};
int main()
{
B b;
b=200;
printf("%d\n",b.Val());
return 0;
}
результат:
a.cpp: In function ‘int main()’:
a.cpp:55: error: no match for ‘operator=’ in ‘b = 200’
a.cpp:43: note: candidates are: B& B::operator=(const B&)
make: *** [a] Error 1
>>>