您的位置:首页 > 编程语言 > C语言/C++

C++技巧之六

2004-02-17 18:47 435 查看

voidmain(void)
{
inti=10;
printf("i:%d/n",i);
{
inti=100;/*Thisstatementisfinesinceitisakintodefining
alocalfunctionwithinthefunction.*/
/*此语句很精炼,
因为它在函数中定义了一局部函数的同族。*/
printf("i:%d/n",i);
}
printf("i:%d/n",i);
}

代码清单6CRecentFileListEx()函数

classCRecentFileListEx:publicCRecentFileList
{
public:
CRecentFileListEx(UINTnStart,LPCTSTRlpszSection,
LPCTSTRlpszEntryFormat,intnSize,
intnMaxDispLen=AFX_ABBREV_FILENAME_LEN):
CRecentFileList(nStart,lpszSection,lpszEntryFormat,nSize,nMaxDispLen)
{
}
BOOLGetDisplayName(CString&strName,intnIndex,
LPCTSTRlpszCurDir,intnCurDir,BOOLbAtLeastName=TRUE)const;
};
BOOLCRecentFileListDlgApp::InitInstance()
{
...
LoadStdProfileSettings();//LoadstandardINIfileoptions(includingMRU)
//载入标准INI文件选项(包括MRU)
//Deletethem_pRecentFileListcreatedintheLoadStdProfileSettings.
//删除在LoadStdProfileSettings中创建的m_pRecentFileList。
deletem_pRecentFileList;
//ThenSizeargumentoftheconstructorissettofourbecausethe
//LoadStdProfileSettingstakesadefaultoffour.Ifyouspecifya
//differentvalueforthenMaxMRUargumentyouneedtochangethe
//nSizeargumentfortheconstructorcall.
//因为LoadStdProfileSettings取默认值4,所以构造器的nSize参数设置为4。
//如果你为nMaxMRU参数指定不同的值,你需要为构造器呼叫而改变nSize参数。
m_pRecentFileList=newCRecentFileListEx(0,FileSection,FileEntry,4);
m_pRecentFileList->ReadList();
...
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: