Народ подскажите пожалуйста почему не работает оператор приведения типа в такой конструкции
(visual studio 2003)
class A
{
public:
int a;
A():a(0){};
A& operator=(const A copy)
{
a=copy.a;
return *this;
}
};
class B:public A
{
public:
int b;
B():b(0)
{}
operator A()
{
A A1;
A1.a=b-1;
return A1;
}
B& operator=(const B copy)
{
b=copy.b;
a=copy.a;
return *this;
}
};
class C:public B
{
public :
int c;
C():
c(0)
{
}
operator B()
{
B B1;
B1.b=c-1;
return B1;
}
C& operator=(const C copy)
{
c=copy.c;
b=copy.b;
a=copy.a;
return *this;
}
};
int main(void)
{
C c;
c.c=5;
std::cout<<((B)c).b;//Здесь хотелось бы чтобы вывелось 4
return 0;
}