| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2768 人关注过本帖
标题:'graphics.h‘不是头文件吗?(我用的是VC++ 6.0)
只看楼主 加入收藏
lin471306489
Rank: 4
等 级:业余侠客
帖 子:136
专家分:247
注 册:2011-8-16
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:4 
'graphics.h‘不是头文件吗?(我用的是VC++ 6.0)
fatal error C1083: Cannot open include file: 'graphics.h': No such file or directory
上面是调试的错误


//
// *****************************************************************
// 图形的基本单元是屏幕上单个点,可以专门用来描述屏幕位置 location,
// 由它派生出具有显示,隐去,放大,缩小和移动功能的类 point,再从类
// point 派生出圆类 circles,在 circles 类中将 location 类的数据成员
// 作圆心。
//

// 在声明 location 类时,类中的 x,y 为保护成员,这样允许共有派生类
// point 直接访问它,并且 想,y 在point 类中也是保护成员,由于 circles
// 是由point 派生而来,所以 circles 也可以直接对想 x,y进行操作。
//
// ******************************************************************
//
//

#include <graphics.h>
#include <conio.h>

calss location {                  // 声明类 location
protected:
    int x,y;                      // x,y为保护成员
public:
    location(int intx,int inty);  // 基类构造函数
};


class point: public location {    // 声明类 point 为类 location 的公有
                                  //  派生类
public:
    point(int intx,int inty);
    void show();                  // 用当前颜色画点
    void hide();                  // 抹去显示的点
    void moveto(int newx,int newy);   // 移动当前的点
};

class circles: private point {        // 声明类 circles 为类 point 的
                                      // 私有派生
public:
    circles(int intx,int inty,int initradius);
    void show();                      // 画一个圆
    void hide();                      // 抹去已显示的圆
    void expand(int expandby);        // 放大显示的圆
    void moveto(int nx,int ny);       // 移动显示的圆
    void contract(int contractby);    // 缩小显示的圆
};

/****** location 类******/
location::location(int intx,int inty) // 定义基类构造函数
{
    x=intx;
    y=inty;
}   

/****** point 类******/
point::point(int intx,int inty):location(intx,inty)
{ }          // 类 point 的构造函数,缀上类 location 的构造函数

void point::show()
{  putpixel(x,y,getcolor()); }        // 用当前颜色画点

void point::hide()
{  putpixel(x,y,getbkcolor()); }      // 用背景颜色画点,相当于抹去点

void point::void moveto(int newx,int newy)  // 在屏幕上移动点
{
    hide();                           // 抹去原有的点
    x=newx;                           // 设置新坐标位置
    y=newy;                           
    show();                           // 画新点
}

/****** circles *******/
circles::circles(int intx,int inty,int initradius)
   :point(intx,inty)      // 类circles的构造函数,缀上类point的构造函数
{  radius=initradius; }

void circles::show()
{  circle(x,y,radius); }              // 画一个圆

void circles::hide()
{
    unsigned int tempcolor;
    tempcolor=getcolor();             // 取出当前色
    setcolor(getbkcolor());           // 将背景色设置为当前色
    circle(x,y,radius);               // 用背景色画圆,相当于抹去圆
    setcolor(tempcolor);              // 将当前颜色恢复到原来状态
}

void circles::expand(int expandby)
{
    hide();                           // 删去原来的圆
    radius+=expandby;                 // 增大圆半径
    if(radius<0)
        radius=0;
    show();                           // 画新圆
}

void circles::contract(int contractby)
{  expand(-contractby); }             // 缩小圆

void circles::moveto(int nx,int ny)
{                                     // 移动圆
    hide();
    x=newx;
    y=newy;
    show();
}


main()
{
    int gdriver=DETECT,gmode;
    initgraph(&gdriver,&gmode,"c:..\\bgi"); // 初始化图形模式
    circles mycircle(100,200150);     // 定义一个圆对象
    setcolor(10);                     // 设置颜色
    mycircle.show();                  // 画一个圆
    getch();                          // 等待键入一个任意键
    mycircle.moveto(200,250);         // 移动一个圆
    getch();                          
    mycircle.expand(50);              // 放大一个圆
    getch();
    mycircle.contract(75);            // 缩小一个圆
    getch();
    closegrapg();                     // 关闭图形方式
    return 0;
}

搜索更多相关主题的帖子: 声明 图形 include file 
2011-09-23 18:41
laoyang103
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:内蒙古包头
等 级:贵宾
威 望:19
帖 子:3082
专家分:11056
注 册:2010-5-22
收藏
得分:5 
那是TC的图形库  VC没有  你可以用MFC 或者Win32 App做图形

                                         
===========深入<----------------->浅出============
2011-09-23 18:50
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:5 
问题很有趣,楼主知道头文件是什么东西?

授人以渔,不授人以鱼。
2011-09-23 19:39
落叶深蓝色
Rank: 8Rank: 8
来 自:山东
等 级:蝙蝠侠
帖 子:319
专家分:807
注 册:2010-12-8
收藏
得分:5 
TC的东东嘛
2011-09-23 21:29
jingchao1021
Rank: 1
等 级:新手上路
帖 子:4
专家分:5
注 册:2011-9-21
收藏
得分:5 
VC++6.0里面有自己的图形库,这个是TC里面的头文件!VC++不支持啊!我以前也犯过同样的错误!
2011-09-23 23:03
快速回复:'graphics.h‘不是头文件吗?(我用的是VC++ 6.0)
数据加载中...
 
   



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

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