请帮助更正简单的MFC调试出错问题

流星落2013 2008-03-23 11:18:31
问题1、我想问下一般的C++的代码用什么工具去调试,测试结果的?

问题2、帮我查错
下面是我用VC新建Project/Win32 Application/下的一个8.5文件夹名,An empty project
后再添加一个C++ source File,加入代码如下:

#include"iostream.h"
#define PI 3.1415926
class CPoint //定义一个点类
{
public:
CPoint(int a,int b) //只有一个有参构造函数
{x=a;
y=b;
cout < <"Construct a point object." < <endl;
}
~CPoint() //点类的析构函数
{
cout < <"Deconstruct of a point object is called." < <endl;
}
void SetPointPosition(int a,int b) //设置点位置的函数定义
{
x=a;y=b;
}
void OutPoint(); //声明点输出函数
private:
int x,y; //存放点位置的数据成员
};
void CPoint::OutPoint() //只有一个有参构造函数
{
cout < <"(" < <x < <"," < <y < <")";
}
class CCircle //定义一个圆类
{
public:
double r; //存放圆半径
CCircle() //声明圆对象的无参构造函数
{
s=r=0;
cout < <"Construct a circle object with 0 value." < <endl;
}
CCircle(double a) //声明对象的有参构造函数
{
r=a;s=0;
cout < <"Construct a circle object with a parameter." < <endl;
}
void SetValue(double a); //设置圆半径的函数声明
double CalculateArea(); //计算圆面积的函数声明
void OutCircleArea(); //输出圆面积的函数声明
~CCircle()
{
cout < <"Deconstruct of a circle object is called" < <endl;
}
protected:
double s; //存放圆的面积
};
double CCircle::CalculateArea()
{
s=r*r*PI;
return(s);
}
void CCircle::OutCircleArea()
{
cout < <"Circle Area=" < <s < <endl;
}
void CCircle::SetValue(double a)
{
r=a;s=0;
}
class CCircleInReferenceFrame:public CCircle //从基类CCircle派生创建新类
{
public:
CCircleInReferenceFrame():pt(0,0) //派生类的无参构造函数
{
cout < <"Construct a circle object in reference frame with 0 value." < <endl;
}
//下面是派生类的有参构造函数,注意对象成员和基类的构造函数调用
CCircleInReferenceFrame(double a,int x0,int y0):CCircle(a),pt(x0,y0)
{
cout < <"Construct a circle object in reference frame with parameters." < <endl;
}
~CCircleInReferenceFrame() //派生类的析构函数
{
cout < <"Deconstruct of a circle object in reference frame is called" < <endl;
}
void SetCirclePosition(int x0,int y0); //设置圆坐标系统中的位置
void OutCircleInfo();
protected:
CPoint pt; //在平面坐标系统中,圆的中心的坐标点
};
void CCircleInReferenceFrame::SetCirclePosition(int x0,int y0)
{
pt.SetPointPosition(x0,y0);
}
void CCircleInReferenceFrame::OutCircleInfo()
{
cout < <"This Circle Object is located in";
pt.OutPoint();
cout < <".\n";
CalculateArea();
OutCircleArea();
}
//下面定义主函数,在主函数中,声明平面坐标系统中的圆对象并加以应用
void main()
{
CCircleInReferenceFrame obj1(10.0,100,45),obj2;
obj1.OutCircleInfo();

obj2.SetValue(2);
obj2.SetCirclePosition(88,66);
obj2.OutCircleInfo();
}

运行时出错如下:
--------------------Configuration: 8_5 - Win32 Debug--------------------
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/8_5.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

8_5.exe - 2 error(s), 0 warning(s)


请问怎么解决
...全文
36 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
流星落2013 2008-03-24
  • 打赏
  • 举报
回复
不错,问题已解决,多谢多谢上面那位兄弟.
arong1234 2008-03-23
  • 打赏
  • 举报
回复
VC本身就是一个常用调试工具

你出的错不是运行错误,是编译连接错误
出错的原因是工程类型不对,你的工程应该是console类型的
console类型要main
win32工程需要WinMain
etc
流星落2013 2008-03-23
  • 打赏
  • 举报
回复
请大家注意输出符号"<<".在此论坛会变形的,呵呵
流星落2013 2008-03-23
  • 打赏
  • 举报
回复
请大家注意<<符号,因为在此论坛中会变形的

16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧