此功能顶部的功能 [英] What is going on at the top of this function
问题描述
我目前正在看一个函数示例,我似乎无法在Visual C ++中使用MFC弄清楚.功能如下
I'm currently looking at a function example that I can't seem to figure out using MFC in Visual C++. The function is as follows
CMFC_OSG_MDIView::CMFC_OSG_MDIView() :mOSG(0L)
{
}
我了解这里的所有内容,除了mOSG(0L)代码段.在MFC_OSG _MDIView类中声明了mOSG,如下所示:
I understand everything here except the mOSG(0L) snippet. mOSG was declared in the MFC_OSG _MDIView class as follows:
cOSG* mOSG;
推荐答案
CMFC_OSG_MDIView::CMFC_OSG_MDIView() :mOSG(0L)
{
}
上面是一个名为 CMFC_OSG_MDIView
的类的构造函数.:mOSG(0L)
称为 initializer list
,在创建对象时执行.初始化列表在构造函数的主体之前被调用,它是初始化成员变量的正确位置.
The above is a constructor, for a class called CMFC_OSG_MDIView
. :mOSG(0L)
is called initializer list
, which is executed when an object is created. The init-list gets called before the body of the constructor, and it is the correct place to initialize the member variables.
这篇关于此功能顶部的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!