读书人

出现异常求高手error C2228: le

发布时间: 2012-07-29 15:26:13 作者: rapoo

出现错误,求高手——error C2228: left of '.Create' must have class/struct/union type
编程出现错误,求高手,代码如下——
// MapxSampleView.cpp : implementation of the CMapxSampleView class
//
#include "MapX.h"
ClaSS CMapxSampleVieW : publiC CView
{
protected;
CMapX m_ctrlMapX;
}
#include "stdafx.h"
#include "MapxSample.h"

#include "MapxSampleDoc.h"
#include "MapxSampleView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMapxSampleView

IMPLEMENT_DYNCREATE(CMapxSampleView, CView)

BEGIN_MESSAGE_MAP(CMapxSampleView, CView)
//{{AFX_MSG_MAP(CMapxSampleView)
ON_WM_CREATE()
ON_WM_SIZE()
ON_WM_SETFOCUS()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMapxSampleView construction/destruction

CMapxSampleView::CMapxSampleView()
{
// TODO: add construction code here

}

CMapxSampleView::~CMapxSampleView()
{
}

BOOL CMapxSampleView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs

return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMapxSampleView drawing

void CMapxSampleView::OnDraw(CDC* pDC)
{
CMapxSampleDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CMapxSampleView printing

BOOL CMapxSampleView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}

void CMapxSampleView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}

void CMapxSampleView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CMapxSampleView diagnostics

#ifdef _DEBUG
void CMapxSampleView::AssertValid() const
{
CView::AssertValid();
}

void CMapxSampleView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}

CMapxSampleDoc* CMapxSampleView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMapxSampleDoc)));
return (CMapxSampleDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMapxSampleView message handlers

int CMapxSampleView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;

//使用默认的大小创建地图,在resize消息影射函数中调整地图的大小,使它充满整个//客户区
if(!m_ctrlMapX.Create(NULL,WS_VISIBLE,CRect(0,0,100,100),this,IDC_MAP))
return -1;
return 0;
}

void CMapxSampleView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);

//调整地图的大小,使它充满整个客户区
if(cx != 0 && cy != 0)
m_ctrlMapX.MoveWindow(0,0,cx,cy,TRUE);
}

void CMapxSampleView::OnSetFocus(CWnd* pOldWnd)
{
CView::OnSetFocus(pOldWnd);



m_ctrlMapX.SetFocus();
}
然后调试就出现以下错误——
--------------------Configuration: MapxSample - Win32 Debug--------------------
Compiling...
MapxSampleView.cpp
D:\Program Files\Microsoft Visual Studio\Visual C++ 6.0\MSDev98\MyProjects\MapxSample\MapxSampleView.cpp(118) : error C2065: 'm_ctrlMapX' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\Visual C++ 6.0\MSDev98\MyProjects\MapxSample\MapxSampleView.cpp(118) : error C2228: left of '.Create' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\Visual C++ 6.0\MSDev98\MyProjects\MapxSample\MapxSampleView.cpp(129) : error C2228: left of '.MoveWindow' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\Visual C++ 6.0\MSDev98\MyProjects\MapxSample\MapxSampleView.cpp(136) : error C2228: left of '.SetFocus' must have class/struct/union type
执行 cl.exe 时出错.

MapxSample.exe - 1 error(s), 0 warning(s)


[解决办法]
貌似CMapX没声明
[解决办法]
楼主看看m_ctrlMapX的声明哦,应该是指针吧
[解决办法]
POINT ERROR
[解决办法]
CMapX m_ctrlMapX;
这句问题

读书人网 >C++

热点推荐