摘要:
【什么时候会生成Copy Constructor?】 当无法应用 bitwise copy semantics时,就会生成copy constructor。以下4种情形,会生成copy constructor: 1、内含“带 copy constructor"的成员对象时。此时要在copy constructor中插入调用成员对象copy constructor的代码。 2、继承“带 copy constructor”的类时。此时要在copy constructor中插入调用成员对象copy constructor的代码。 3、声明了 virtual 函数时。此时要在copy con 阅读全文
posted @ 2013-05-29 23:46
Tekkaman
阅读(272)
评论(0)
推荐(0)
摘要:
【何时会生成default constructor?】 1、带有"Default Constructor"的Member Class Object。 对于Class Object成员,编译器默认会调用此成员的默认构造函数。那么在哪调呢?答案是本对象的默认构造函数。所以编译器会生成Default Constructor。 2、带有"Default Constructor"的Base Class。 对于继承的情况,编译器默认会调用此类父类的默认构造函数。同上,在本对象的默认构造函数里调,所以需要生成Default Constructor。 3、带有" 阅读全文
posted @ 2013-05-29 21:18
Tekkaman
阅读(311)
评论(0)
推荐(0)
浙公网安备 33010602011771号