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

C++中构造函数的三种调用问题解析
引用本文:方莹,吴凤娟.C++中构造函数的三种调用问题解析[J].数字社区&智能家居,2007,2(5):705-705,734.
作者姓名:方莹  吴凤娟
作者单位:商丘师范学院计算机科学系,河南商丘476000
摘    要:构造函数是一种用于创建对象的特殊成员函数,构造函数的调用顺序问题对类的定义至关重要,本文从简单类对象的创建、类组合(一个类的对象是另一个类的数据成员)和类继承三种情况下分析了构造函数的调用问题,一定程度上诠释了类定义中的这一关键因素,为更好掌握C++的编程思想提供了理论依据和程序示例。

关 键 词:构造函数  调用  继承  对象
文章编号:1009-3044(2007)09-20705-01
修稿时间:2007-04-04

Analysis of Three Problems of the Constructor Calling in C++
FANG Ying, WU Feng-juan.Analysis of Three Problems of the Constructor Calling in C++[J].Digital Community & Smart Home,2007,2(5):705-705,734.
Authors:FANG Ying  WU Feng-juan
Affiliation:Computer Science Dept., Shangqiu Normal University, Shangqiu 476000, China
Abstract:The constructor is a special member function which is used to construct the object. The problem of the calling order of the constructor is very important to the definition of the class. In this paper we analyse the problem in three different aspects. The constructor will be called firstly when we construct only one object, secondly when there is the class compositon(the object of a class is the data member of another class), and finally when there is the class inheritance. We try to explain the vital factor in the class definition in some degree. In this paper we try to supply theoretical basis and programm example for us to grasp the programming idea of C++ better.
Keywords:constructor  calling  inheritance  object
本文献已被 CNKI 维普 等数据库收录!
设为首页 | 免责声明 | 关于勤云 | 加入收藏

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