首页 | 本学科首页   官方微博 | 高级检索  
     

C++程序设计中构造函数的探讨
引用本文:李欣然,靳雁霞.C++程序设计中构造函数的探讨[J].计算机时代,2011(12):30-32.
作者姓名:李欣然  靳雁霞
作者单位:1. 中北大学电子与计算机科学技术学院,山西太原,030051
2. 中北大学仪器科学与动态测试教育部重点实验室
摘    要:首先介绍了类的构造函数特征和分类,举例说明了组合类对象和派生类对象构造函数的构造方法及调用次序;其次研究了使用缺省拷贝构造函数时,如果类中包含new运算符而导致指针挂起的原因,并给出了解决方法;最后介绍了转换构造函数的功能及使用转换构造函数进行类型转换的步骤。

关 键 词:C++  构造函数  派生类构造函数  拷贝构造函数  转换构造函数

Discussion on Constructors in C++ Programming
LI Xin-ran,Jin Yan-xia.Discussion on Constructors in C++ Programming[J].Computer Era,2011(12):30-32.
Authors:LI Xin-ran  Jin Yan-xia
Affiliation:1. School of Electronics and Computer Science & Technology, North University of China, Taiyuan, Shanxi 030051, China; 2. Ministry of Education Key Laboratory of Instrumentation Science and Dynamic Measurement, North University of China)
Abstract:First we introduce the features and classification of class constructors, and illustrate the constructing methods and call order of combined class object and derived class object constructors, then give the solution to pointer hung caused by operator new in class while using default copy constructor, finally introduce the functions of conversion constructor and the procedure of type conversion by using conversion constructor
Keywords:C++  constructor  derived class constructor  copy constructor  conversion constructor
本文献已被 CNKI 维普 万方数据 等数据库收录!
设为首页 | 免责声明 | 关于勤云 | 加入收藏

Copyright©北京勤云科技发展有限公司  京ICP备09084417号