C++有问题!!!!! 15
//#include"stdafx.h"#include"DDATest.h"#include"StdAfx.h"#include"DDATestDoc.h"#inclu...
//
#include "stdafx.h"
#include "DDATest.h"
#include "StdAfx.h"
#include "DDATestDoc.h"
#include "DDATestView.h"
#include "LineDlg.h"
#include "Line.h"
#include "MainFrm.h"
#define ROUND(a)((int)(a+0.5))
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// CDDATestView
IMPLEMENT_DYNCREATE(CDDATestView, CView)
BEGIN_MESSAGE_MAP(CDDATestView, CView)
//{{AFX_MSG_MAP(CDDATestView)
ON_COMMAND(ID_DRAWLINE_DDA, OnDrawlineDda)
//}}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()
// CDDATestView construction/destruction
CDDATestView::CDDATestView()
{
// TODO: add construction code here
}
CDDATestView::~CDDATestView()
{
}
BOOL CDDATestView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
// CDDATestView drawing
void CDDATestView::OnDraw(CDC* pDC)
{
CDDATestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
// CDDATestView printing
BOOL CDDATestView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CDDATestView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CDDATestView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
// CDDATestView diagnostics
#ifdef _DEBUG
void CDDATestView::AssertValid() const
{
CView::AssertValid();
}
void CDDATestView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CDDATestDoc* CDDATestView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDDATestDoc)));
return (CDDATestDoc*)m_pDocument;
}
#endif //_DEBUG
// CDDATestView message handlers
void CDDATestView::OnDrawlineDda()
{
// TODO: Add your command handler code here
float x1;
float y1;
float x2;
float y2;
CLineDlg dlg;
if(dlg.DoModal()==IDOK)
{
x1=dlg.m_fXStart;
y1=dlg.m_fYStart;
x2=dlg.m_fXEnd;
y2=dlg.m_fYEnd;
}
CLine * pLine=new CLine(x1,y1,x2,y2);
CDC* pDC=GetDC();
pLine->LineDda(pDC);
void LineDda(float x1,float y1,float x2,float y2)
{int dx=x2-x1,dy=y2-y1,steps,k;
float xIncrement,yIncrement,x=x1,y=y1;
if(abs(dx)>abs(dy))steps=abs(dx);
else steps=abs(dy);
xIncrement=dx/(float)steps;
yincrement=dy/(float)steps;
setPixel(ROUND(x),ROUND(y));
for(k=0;k<steps;k++){
x+=xIncrement;
y+=yIncrement;
setPixel(ROUND(x),ROUND(y));
}
}
}
那位高手能帮我改一下错!!谢谢!!
D:\学习\计算机图形学\DDATest-Frame\DDATestView.cpp(127) : warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data
D:\学习\计算机图形学\DDATest-Frame\DDATestView.cpp(127) : warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data
D:\学习\计算机图形学\DDATest-Frame\DDATestView.cpp(127) : warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data
D:\学习\计算机图形学\DDATest-Frame\DDATestView.cpp(130) : error C2039: 'LineDda' : is not a member of 'CLine'
d:\学习\计算机图形学\ddatest-frame\line.h(15) : see declaration of 'CLine'
D:\学习\计算机图形学\DDATest-Frame\DDATestView.cpp(133) : error C2373: 'LineDda' : redefinition; different type modifiers
D:\学习\计算机图形学\DDATest-Frame\DDATestView.cpp(133) : error C2601: 'LineDda' : local function definitions are illegal
执行 cl.exe 时出错. 展开
#include "stdafx.h"
#include "DDATest.h"
#include "StdAfx.h"
#include "DDATestDoc.h"
#include "DDATestView.h"
#include "LineDlg.h"
#include "Line.h"
#include "MainFrm.h"
#define ROUND(a)((int)(a+0.5))
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// CDDATestView
IMPLEMENT_DYNCREATE(CDDATestView, CView)
BEGIN_MESSAGE_MAP(CDDATestView, CView)
//{{AFX_MSG_MAP(CDDATestView)
ON_COMMAND(ID_DRAWLINE_DDA, OnDrawlineDda)
//}}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()
// CDDATestView construction/destruction
CDDATestView::CDDATestView()
{
// TODO: add construction code here
}
CDDATestView::~CDDATestView()
{
}
BOOL CDDATestView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
// CDDATestView drawing
void CDDATestView::OnDraw(CDC* pDC)
{
CDDATestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
// CDDATestView printing
BOOL CDDATestView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CDDATestView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CDDATestView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
// CDDATestView diagnostics
#ifdef _DEBUG
void CDDATestView::AssertValid() const
{
CView::AssertValid();
}
void CDDATestView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CDDATestDoc* CDDATestView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDDATestDoc)));
return (CDDATestDoc*)m_pDocument;
}
#endif //_DEBUG
// CDDATestView message handlers
void CDDATestView::OnDrawlineDda()
{
// TODO: Add your command handler code here
float x1;
float y1;
float x2;
float y2;
CLineDlg dlg;
if(dlg.DoModal()==IDOK)
{
x1=dlg.m_fXStart;
y1=dlg.m_fYStart;
x2=dlg.m_fXEnd;
y2=dlg.m_fYEnd;
}
CLine * pLine=new CLine(x1,y1,x2,y2);
CDC* pDC=GetDC();
pLine->LineDda(pDC);
void LineDda(float x1,float y1,float x2,float y2)
{int dx=x2-x1,dy=y2-y1,steps,k;
float xIncrement,yIncrement,x=x1,y=y1;
if(abs(dx)>abs(dy))steps=abs(dx);
else steps=abs(dy);
xIncrement=dx/(float)steps;
yincrement=dy/(float)steps;
setPixel(ROUND(x),ROUND(y));
for(k=0;k<steps;k++){
x+=xIncrement;
y+=yIncrement;
setPixel(ROUND(x),ROUND(y));
}
}
}
那位高手能帮我改一下错!!谢谢!!
D:\学习\计算机图形学\DDATest-Frame\DDATestView.cpp(127) : warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data
D:\学习\计算机图形学\DDATest-Frame\DDATestView.cpp(127) : warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data
D:\学习\计算机图形学\DDATest-Frame\DDATestView.cpp(127) : warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data
D:\学习\计算机图形学\DDATest-Frame\DDATestView.cpp(130) : error C2039: 'LineDda' : is not a member of 'CLine'
d:\学习\计算机图形学\ddatest-frame\line.h(15) : see declaration of 'CLine'
D:\学习\计算机图形学\DDATest-Frame\DDATestView.cpp(133) : error C2373: 'LineDda' : redefinition; different type modifiers
D:\学习\计算机图形学\DDATest-Frame\DDATestView.cpp(133) : error C2601: 'LineDda' : local function definitions are illegal
执行 cl.exe 时出错. 展开
展开全部
错误提示贴出来
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你把头文件,也拿出来,我给你改.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
void LineDda(float x1,float y1,float x2,float y2)
是成员函数,
你怎么给弄成成员函数了?
是成员函数,
你怎么给弄成成员函数了?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询