非C++内建型别A和B,在哪几种情况下B能隐式转换为A

 

主要有一下四种方式

1. B public 继承自 A;

calss B : public A
{
  ...  
}

 2. 在 A中写参数为B的复制构造函数

calss A
{
  A(const B &b);  
}

3. 重写A的= operator 

A & operator(const B& );

 

posted @ 2014-09-26 20:55  hana12169  阅读(308)  评论(0编辑  收藏  举报