1,**************************************************BOOL CUDPcommApp::InitInstance()
{
AfxEnableControlContainer(); // Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif //关于这句new ************
CUDPcommDlg dlg = new CUDPcommDlg();
//****************************************
m_pMainWnd = &dlg;
CListDlg listdlg = new CListDlg();
//m_pMainWnd = &listdlg;
//listdlg.DoModal();
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
} // Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
2************************************************************************
void CUDPcommDlg::OnSetFont()
{
//还有就是这个new**************************
CFontDialog chooseFont = new CFontDialog();
//*****************************************
if(chooseFont.DoModal())
{
LOGFONT lf; chooseFont.GetCurrentFont(&lf); if (pfont != NULL)
{
CFont *oldFont = pfont;
pfont = new CFont();
pfont->CreateFont(lf.lfHeight,lf.lfWidth,0,0,FW_THIN,FALSE,FALSE,
0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
1,15,lf.lfFaceName);
SendMessageToDescendants(WM_SETFONT,(WPARAM)pfont->GetSafeHandle(),
MAKELPARAM( TRUE,0 ));
delete(oldFont);
}
}
}报错信息:
E:\study\mywork\UDPcomm\UDPcommDlg.cpp(660) : error C2440: 'initializing' : cannot convert from 'class CFontDialog *' to 'class CFontDialog'
No constructor could take the source type, or constructor overload resolution was ambiguous
Error executing cl.exe.为什么只有第二出的new不可以?dx指点下!!!谢谢了
{
AfxEnableControlContainer(); // Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif //关于这句new ************
CUDPcommDlg dlg = new CUDPcommDlg();
//****************************************
m_pMainWnd = &dlg;
CListDlg listdlg = new CListDlg();
//m_pMainWnd = &listdlg;
//listdlg.DoModal();
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
} // Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
2************************************************************************
void CUDPcommDlg::OnSetFont()
{
//还有就是这个new**************************
CFontDialog chooseFont = new CFontDialog();
//*****************************************
if(chooseFont.DoModal())
{
LOGFONT lf; chooseFont.GetCurrentFont(&lf); if (pfont != NULL)
{
CFont *oldFont = pfont;
pfont = new CFont();
pfont->CreateFont(lf.lfHeight,lf.lfWidth,0,0,FW_THIN,FALSE,FALSE,
0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
1,15,lf.lfFaceName);
SendMessageToDescendants(WM_SETFONT,(WPARAM)pfont->GetSafeHandle(),
MAKELPARAM( TRUE,0 ));
delete(oldFont);
}
}
}报错信息:
E:\study\mywork\UDPcomm\UDPcommDlg.cpp(660) : error C2440: 'initializing' : cannot convert from 'class CFontDialog *' to 'class CFontDialog'
No constructor could take the source type, or constructor overload resolution was ambiguous
Error executing cl.exe.为什么只有第二出的new不可以?dx指点下!!!谢谢了
#include "stdio.h"
#include "string"
using namespace std;
class Employee{
public:
Employee(){cout<<"no parameter";};
Employee(Employee* str){cout<<"self as parameter";};
~Employee(){};
//virtual print(){};//cout<<"Print of Class Employee"<<endl;}private:
char str;
string aa;
int num;
};
struct list
{
char str;
int num;
char str2;
}_taglist;void main()
{
Employee a = new Employee();
printf("%d\n",sizeof(a));
printf("%d\n",sizeof(_taglist));
//virtualPointer(&a);
}用这个代码试验了下,构造函数确实分别被调用,谢谢tufaqing() ,马上结贴!