主要目的:
本代码主要目的在于探究在组合类中创建以及初始化对象时,各个类的构造函数的调用情况。
/*------------------------------------------------------------------------
功能:探究组合类中构造函数的相关问题
运行结果:
Calling the argument constructor of point... // 对应92行创建点对象p1, p2
Calling the argument constructor of point...
Calling the copy constructor of Point... // 对应93行创建线段对象l1
Calling the copy constructor of Point...
Calling the copy constructor of Point...
Calling the copy constructor of Point...
Calling the argument constructor of Line...
Calling the default constructor of point... // 对应94行创建线段对象l2
Calling the default constructor of point...
Calling the copy constructor of Line...
The length of l1 is: 1.41421 // 对应95行
The length of l2 is: 1.41421 // 对应96行
--------------------------------------------------------------------------
Author: Zhang Kaizhou
Date: 2019-3-31 14:34:09
-------------------------------------------------------------------------*/
#include <iostream>
#include <cmath>
using na

该篇博客深入探讨了C++编程中组合类构造函数的工作原理,详细阐述了在创建和初始化组合类对象时,各组成部分类构造函数的调用顺序和机制。
最低0.47元/天 解锁文章
1683





