| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 738 人关注过本帖
标题:我用c++编了一个简单图形显示的程序,为什莫不能运行,请高手们看看.
只看楼主 加入收藏
无极限
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2005-10-29
收藏
 问题点数:0 回复次数:1 
我用c++编了一个简单图形显示的程序,为什莫不能运行,请高手们看看.

//circle.cpp
#include iostream.h>
#include conio.h>
#include graphics.h>
//两个<>在论坛上看不到,我少写了一个<

enum BOOLEAN
{
FALSE,
TURE
};

//location.cpp
class LOCATION
{
public:
LOCATION(int x,int y)
{ x_pos=x;
y_pos=y;
return;
}

~LOCATION()
{
return;
}

int get_x()
{
return(x_pos);
}

int get_y()
{
return(y_pos);
}

protected:
int x_pos;
int y_pos;
};
//point.cpp
class POINT:public LOCATION
{
public:
POINT(int x,int y):LOCATION(x,y)
{
visable=FALSE;
return;
}

~POINT()
{
return;
}

BOOLEAN is_visable()
{
return(visable);
}

void show()
{
if(!is_visable())
{
visable=TURE;
putpixel(x_pos,y_pos,getcolor()); //draw a circle
}
return;
}

void hide()
{ if(is_visable())
{
visable=FALSE;
putpixel(x_pos,y_pos,getbkcolor());
//draw a circle with backcolor
}
return;
}

void move_to(int x,int y)
{
hide();
x_pos=x;
y_pos=y;
show();
return;
}

protected:
BOOLEAN visable;
};

//circle.cpp
class CIRCLE:public POINT
{
CIRCLE(int x,int y,int r):POINT(x,y)
{
radius=r;
return;
}

~CIRCLE()
{
return;
}

void show()
{
if(!is_visable())
{
visable=TURE;
circle(x_pos,y_pos,radius);//draw a circle
}
return;
}

void hide()
{
if(is_visable())
{
visable=FALSE;
temp_color=getcolor(); //save current color
setcolor(getbkcolor());
circle(x_pos,y_pos,radius);
setcolor(temp_color);
}
return;
}
void move_to(int x,int y)
{
hide();
x_pos=x;
y_pos=y;
show();
return;
}

void expand(int delta)
{
hide();
radius=radius+delta;
if(radius<0) radius=0;
show();
return;
}

void contract(int delta)
{ expand(-delta);
return;
}
protected:
int radius;
int temp_color;
};


int main()
{
int graphdriver=DETECT, graphmode;//define graph valiable
CIRCLE circle(100,200,50);
initgraph(&graphdriver,&graphmode," ");//init graph model


circle.show();
getch();
circle.move_to(200,250);
getch();
circle.expand(50);
getch();
circle.contract(65);
getch();
closegraph(); //close graph model
return 0;

}

搜索更多相关主题的帖子: 图形 pos int get 
2005-11-06 22:53
无极限
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2005-10-29
收藏
得分:0 
我的平台是turboc++3.01

2005-11-06 22:54
快速回复:我用c++编了一个简单图形显示的程序,为什莫不能运行,请高手们看看.
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018016 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved