我从CPropertySheet生成了一个新类CMyProperty,在里面添加了三个成员变量(CPropertyPage类),并加了AddPage()了三个页面
然后,我在SDI的View类里面定义了一个CMyProperty类的成员变量,再进行相关操作
但是编译提示:
E:\vcprog\xxxx\xxxxView.cpp(46) : error C2512: 'CMyProperty' : no appropriate default constructor available为什么呢?
然后,我在SDI的View类里面定义了一个CMyProperty类的成员变量,再进行相关操作
但是编译提示:
E:\vcprog\xxxx\xxxxView.cpp(46) : error C2512: 'CMyProperty' : no appropriate default constructor available为什么呢?
声明:
CMyProperty(LPCTSTR pszCaption);
实现:
CMyProperty::CMyProperty(LPCTSTR pszCaption):CPropertySheet( pszCaption,NULL,0)
{}
我该怎么办?
ParaSheet.h#if !defined(AFX_PARASHEET_H__DA82EB55_E6EC_4542_B49D_81CC8E95C25E__INCLUDED_)
#define AFX_PARASHEET_H__DA82EB55_E6EC_4542_B49D_81CC8E95C25E__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ParaSheet.h : header file
//
#include "CalculatingPage.h"
#include "StructurePage.h"
#include "DiscretePage.h"/////////////////////////////////////////////////////////////////////////////
// CParaSheetclass CParaSheet : public CPropertySheet
{
DECLARE_DYNAMIC(CParaSheet)// Construction
public:
CParaSheet(LPCTSTR pszCaption);// Attributes
public:
CStructurePage m_StructurePara;
CCalculatingPage m_CalculatingPara;
CDiscretePage m_DiscretePara;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CParaSheet)
//}}AFX_VIRTUAL// Implementation
public:
virtual ~CParaSheet(); // Generated message map functions
protected:
//{{AFX_MSG(CParaSheet)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_PARASHEET_H__DA82EB55_E6EC_4542_B49D_81CC8E95C25E__INCLUDED_)
ParaSheet.cpp// ParaSheet.cpp : implementation file
//#include "stdafx.h"
#include "GCFE.h"
#include "ParaSheet.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/////////////////////////////////////////////////////////////////////////////
// CParaSheetIMPLEMENT_DYNAMIC(CParaSheet, CPropertySheet)
CParaSheet::CParaSheet(LPCTSTR pszCaption)
:CPropertySheet(pszCaption, NULL, 0)
{
AddPage(&m_DiscretePara);
AddPage(&m_CalculatingPara);
AddPage(&m_StructurePara);
}CParaSheet::~CParaSheet()
{
}
BEGIN_MESSAGE_MAP(CParaSheet, CPropertySheet)
//{{AFX_MSG_MAP(CParaSheet)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CParaSheet message handlersMyView.h中………………
CParaSheet m_Sheet;
……………………
MyView.cppCGCFEView::CGCFEView()
{ //调试时,指示错误位置是这里,就是这个打括号这里
………………
}