一个简单的错误

Talor 2008-04-09 09:34:08
D:\张祥VC\ShowBMP\ShowBMPDlg.cpp(185) : error C2601: 'LoadShowBMPFile' : local function definitions are illegal
这个是怎么回事?
...全文
87 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
scq2099yt 2008-04-09
  • 打赏
  • 举报
回复
少了一个}
iyranly 2008-04-09
  • 打赏
  • 举报
回复
同意五六楼
cnzdgs 2008-04-09
  • 打赏
  • 举报
回复
同5楼,少了一个}。
hxingz 2008-04-09
  • 打赏
  • 举报
回复
定义LoadShowBMPFile(const char *pPathname=NULL); 的时候加上
BOOL,使它与实现该函数的返回值一致。
菜牛 2008-04-09
  • 打赏
  • 举报
回复
void CShowBMPDlg::OnButton1()
{
// TODO: Add your control notification handler code here
char szFilter[] = "BMP Files (*.bmp) ¦*.bmp ¦All Files (*.*) ¦*.* ¦ ¦";
CFileDialog dlg( TRUE,"BMP",NULL,OFN_HIDEREADONLY ¦ OFN_OVERWRITEPROMPT,szFilter );
if(dlg.DoModal() == IDOK)
{
CString strPathName = dlg.GetPathName();
}
少了一个}
当然,你肯定还丢了其他代码。
Talor 2008-04-09
  • 打赏
  • 举报
回复
void CShowBMPDlg::OnButton1()
{
// TODO: Add your control notification handler code here
char szFilter[] = "BMP Files (*.bmp)|*.bmp|All Files (*.*)|*.*||";
CFileDialog dlg( TRUE,"BMP",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilter );
if(dlg.DoModal() == IDOK)
{
CString strPathName = dlg.GetPathName();
}

//将内存中的BMP文件内容转换到HBITMAP
BOOL CShowBMPDlg::LoadShowBMPFile(const char *pPathname)
{
CFile file;
if( !file.Open( pPathname, CFile::modeRead) )
return FALSE;
DWORD m_nFileLen;
m_nFileLen = file.GetLength();
m_pBMPBuffer = new char[m_nFileLen + 1];
if(!m_pBMPBuffer)
return FALSE;
if(file.ReadHuge(m_pBMPBuffer,m_nFileLen) != m_nFileLen)
return FALSE;
return TRUE;
}
D:\张祥VC\ShowBMP\ShowBMPDlg.cpp(185) : error C2601: 'LoadShowBMPFile' : local function definitions are illegal

就是这样的

头文件是这样的:
class CShowBMPDlg : public CDialog
{
// Construction
public:
CShowBMPDlg(CWnd* pParent = NULL); // standard constructor
LoadShowBMPFile(const char *pPathname=NULL);
// Dialog Data
//{{AFX_DATA(CShowBMPDlg)
enum { IDD = IDD_SHOWBMP_DIALOG };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA

// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CShowBMPDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:
HICON m_hIcon;

// Generated message map functions
//{{AFX_MSG(CShowBMPDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnButton1();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_SHOWBMPDLG_H__64497118_014D_4CDB_8F74_6AB894713691__INCLUDED_)
快乐鹦鹉 2008-04-09
  • 打赏
  • 举报
回复
函数定义不正确。贴出来
aniuman 2008-04-09
  • 打赏
  • 举报
回复
仔细检查下代码就会解决
wwoo_1105 2008-04-09
  • 打赏
  • 举报
回复
贴上代码瞧瞧
abuseyoudna1981 2008-04-09
  • 打赏
  • 举报
回复
BOOL CShowBMPDlg::LoadShowBMPFile(const char *pPathname)
---------------------------------------------------------
把CPP文件改成
BOOL CShowBMPDlg::LoadShowBMPFile(const char *pPathname/*= NULL*/)

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧