visual studio 2010 - MFC C++ LNK 2019 ERROR -
i trying "file save as" programming code inside mfc application.
in testdlg.h header file have got
public: bool savefile (lpctstr pszfile); cstring m_strpathname;
and in testdlg.cpp cpp file have got
void ctestdlg::onsavefile() { tchar szfilters[] = _t ("text files (*.txt)¦*.txt¦all files (*.*)¦*.*¦¦"); cfiledialog dlg (false, _t ("txt"), _t ("*.txt"), ofn_overwriteprompt | ofn_pathmustexist | ofn_hidereadonly, szfilters); if (dlg.domodal () == idok) { if (savefile (dlg.getpathname ())) m_strpathname = dlg.getpathname (); } }
after this, build solution , got error.
lnk2019: unresolved external symbol "public: int __thiscall ctestdlg::savefile(wchar_t const *)" (?savefile@ctestdlg@@qaehpb_w@z) referenced in function "public:
how resolve this?? appreciated. thank you.
edit.
after removing if (savefile (dlg.getpathname ())
line, file can build , run when ever press save button, no file saved.
it not mfc or internal error programming error.
when declare method in .h file body of method should present in .cpp file.else give linking error of function not found in .obj file. solution use same function in .h , .cpp file like, in .h file,
public: bool savefile (lpctstr pszfile); cstring m_strpathname;'
and in .cpp file,
void ctestdlg::onsavefile(lpctstr pszfile) { tchar szfilters[] = _t ("text files (*.txt)¦*.txt¦all files (*.*)¦*.*¦¦"); cfiledialog dlg (false, _t ("txt"), _t ("*.txt"), ofn_overwriteprompt | ofn_pathmustexist | ofn_hidereadonly, szfilters); if (dlg.domodal () == idok) { if (savefile (dlg.getpathname ())) m_strpathname = dlg.getpathname (); } }
Comments
Post a Comment