C++技巧之六

 
 
   
   
void main(void)
   
   
{
   
   
                    int i = 10;
   
   
                    printf("i: %d/n", i);
   
   
                    {
   
   
                    int i = 100;            /* This statement is fine since it is akin to defining
   
   
                                                                       a local function within the function. */
   
   
/* 此语句很精炼,
  
  
因为它在函数中定义了一局部函数的同族。*/
   
   
                    printf("i: %d/n", i);
   
   
                    }
   
   
                    printf("i: %d/n", i);
   
   
}
   
   
 
   
   
代码清单 6 CRecentFileListEx()函数
class CRecentFileListEx : public CRecentFileList
   
   
{
   
   
public:
   
   
    CRecentFileListEx(UINT nStart, LPCTSTR lpszSection,
   
   
        LPCTSTR lpszEntryFormat, int nSize,
   
   
        int nMaxDispLen = AFX_ABBREV_FILENAME_LEN):  
   
   
        CRecentFileList(nStart, lpszSection, lpszEntryFormat, nSize, nMaxDispLen)
   
   
    {
   
   
    }
   
   
                                         
   
   
    BOOL GetDisplayName(CString& strName, int nIndex,
   
   
        LPCTSTR lpszCurDir, int nCurDir, BOOL bAtLeastName = TRUE) const;
   
   
};
   
   
 
   
   
BOOL CRecentFileListDlgApp::InitInstance()
   
   
{
   
   
    ...
   
   
                
   
   
    LoadStdProfileSettings();  // Load standard INI file options (including MRU)
   
   
// 载入标准INI文件选项(包括MRU)
   
   
// Delete the m_pRecentFileList created in the LoadStdProfileSettings.
   
   
// 删除在LoadStdProfileSettings中创建的m_pRecentFileList
  
  
    delete m_pRecentFileList;
   
   
 
   
   
    // The nSize argument of the constructor is set to four because the  
   
   
    // LoadStdProfileSettings takes a default of four.  If you specify a  
   
   
    // different value for the nMaxMRU argument you need to change the
   
   
// nSize argument for the constructor call.
   
   
// 因为LoadStdProfileSettings 取默认值4,所以构造器的nSize参数设置为4
  
  
// 如果你为nMaxMRU参数指定不同的值,你需要为构造器呼叫而改变nSize参数。
  
  
    m_pRecentFileList = new CRecentFileListEx(0, FileSection, FileEntry, 4);
   
   
    m_pRecentFileList->ReadList();
   
   
 
   
   
    ...
   
   
}
   
   
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值