class name
{
name( int a=0,char b=0)
}
第二种是在.cpp的实现里将成员初始化为0,类似:
name::name(int a,int b)
{
a=0
b=0
}
至于选哪一种,就看自己的喜好了,如果是我,我选第一种,将此构造函数作为默认构造函数。
CWinApp()的构造函数定义在appcore.cpp中,CWinApp类定义在afxwin.h
构造函数:CWinApp::CWinApp(LPCTSTR lpszAppName)
{
if (lpszAppName != <a href="https://www.baidu.com/s?wd=NULL&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dBn1uhnjwWnvDvuhcLnjbd0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6K1TL0qnfK1TL0z5HD0IgF_5y9YIZ0lQzqlpA-bmyt8mh7GuZR8mvqVQL7dugPYpyq8Q1cvPj63rHT4rHmkn10dPWm3Pf" target="_blank" class="baidu-highlight">NULL</a>)
m_pszAppName = _tcsdup(lpszAppName)
else
m_pszAppName = <a href="https://www.baidu.com/s?wd=NULL&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dBn1uhnjwWnvDvuhcLnjbd0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6K1TL0qnfK1TL0z5HD0IgF_5y9YIZ0lQzqlpA-bmyt8mh7GuZR8mvqVQL7dugPYpyq8Q1cvPj63rHT4rHmkn10dPWm3Pf" target="_blank" class="baidu-highlight">NULL</a>
// initialize CWinThread state
AFX_MODULE_STATE* pModuleState = _AFX_CMDTARGET_GETSTATE()
AFX_MODULE_THREAD_STATE* pThreadState = pModuleState->m_thread
ASSERT(AfxGetThread() == <a href="https://www.baidu.com/s?wd=NULL&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dBn1uhnjwWnvDvuhcLnjbd0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6K1TL0qnfK1TL0z5HD0IgF_5y9YIZ0lQzqlpA-bmyt8mh7GuZR8mvqVQL7dugPYpyq8Q1cvPj63rHT4rHmkn10dPWm3Pf" target="_blank" class="baidu-highlight">NULL</a>)
pThreadState->m_pCurrentWinThread = this
ASSERT(AfxGetThread() == this)
m_hThread = ::GetCurrentThread()
m_nThreadID = ::GetCurrentThreadId()
// initialize CWinApp state
ASSERT(afxCurrentWinApp == NULL) // only one CWinApp object please
pModuleState->m_pCurrentWinApp = this
ASSERT(AfxGetApp() == this)
// in non-running state until WinMain
m_hInstance = NULL
m_pszHelpFilePath = NULL
m_pszProfileName = NULL
m_pszRegistryKey = NULL
m_pszExeName = NULL
m_pRecentFileList = NULL
m_pDocManager = NULL
m_atomApp = m_atomSystemTopic = NULL
m_lpCmdLine = NULL
m_pCmdInfo = NULL
// initialize wait cursor state
m_nWaitCursorCount = 0
m_hcurWaitCursorRestore = NULL
// initialize current printer state
m_hDevMode = NULL
m_hDevNames = NULL
m_nNumPreviewPages = 0 // not specified (defaults to 1)
// initialize DAO state
m_lpfnDaoTerm = NULL // will be set if AfxDaoInit called
// other initialization
m_bHelpMode = FALSE
m_nSafetyPoolSize = 512 // default size
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)