在视图类声明成员变量
public:
CRect m_rRect1;
cRect m_rRect2;
在构造函数初始化
CRecRecView::CRecRecView():m_rRect1(50,50,250,200),m_rRect2(100,120,300,400)
void CRecRecView::OnDraw(CDC* pDC)
{
CRecRecDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
int x1,y1;
int x2,y2;
if(m_rRect1.left<m_rRect2.left)
x1=m_rRect2.left;
else
x1=m_rRect1.left;
if(m_rRect1.top<m_rRect2.top)
y1=m_rRect2.top;
else
y1=m_rRect1.top;
if(m_rRect1.right<m_rRect2.right)
x2=m_rRect2.right;
else
x2=m_rRect1.right;
if(m_rRect1.bottom<m_rRect2.bottom)
y2=m_rRect2.bottom;
else
y2=m_rRect1.bottom;
pDC->Ellipse(x1,x2,y1,y2);
}
--------------------Configuration: RecRec - Win32 Debug--------------------
Compiling...
RecRec.cpp
d:\program files\microsoft visual studio\myprojects\recrec\recrecview.h(17) : error C2146: syntax error : missing ';' before identifier 'm_rRect2'
d:\program files\microsoft visual studio\myprojects\recrec\recrecview.h(17) : error C2501: 'cRect' : missing storage-class or type specifiers
d:\program files\microsoft visual studio\myprojects\recrec\recrecview.h(17) : error C2501: 'm_rRect2' : missing storage-class or type specifiers
RecRecView.cpp
d:\program files\microsoft visual studio\myprojects\recrec\recrecview.h(17) : error C2146: syntax error : missing ';' before identifier 'm_rRect2'
d:\program files\microsoft visual studio\myprojects\recrec\recrecview.h(17) : error C2501: 'cRect' : missing storage-class or type specifiers
d:\program files\microsoft visual studio\myprojects\recrec\recrecview.h(17) : error C2501: 'm_rRect2' : missing storage-class or type specifiers
D:\Program Files\Microsoft Visual Studio\MyProjects\RecRec\RecRecView.cpp(36) : error C2614: 'CRecRecView' : illegal member initialization: 'm_rRect2' is not a base or member
D:\Program Files\Microsoft Visual Studio\MyProjects\RecRec\RecRecView.cpp(63) : error C2065: 'm_rRect2' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\MyProjects\RecRec\RecRecView.cpp(63) : error C2228: left of '.left' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\MyProjects\RecRec\RecRecView.cpp(64) : error C2228: left of '.left' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\MyProjects\RecRec\RecRecView.cpp(67) : error C2228: left of '.top' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\MyProjects\RecRec\RecRecView.cpp(68) : error C2228: left of '.top' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\MyProjects\RecRec\RecRecView.cpp(71) : error C2228: left of '.right' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\MyProjects\RecRec\RecRecView.cpp(72) : error C2228: left of '.right' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\MyProjects\RecRec\RecRecView.cpp(75) : error C2228: left of '.bottom' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\MyProjects\RecRec\RecRecView.cpp(76) : error C2228: left of '.bottom' must have class/struct/union type
Generating Code...
Error executing cl.exe.
RecRec.exe - 16 error(s), 0 warning(s)
不知道哪错了,谢谢 ,辛苦大家!!帮忙指点,谢谢了!!!