| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 439 人关注过本帖
标题:[讨论]关于头文件的设置
只看楼主 加入收藏
疯之子rlb
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2006-3-1
收藏
 问题点数:0 回复次数:0 
[讨论]关于头文件的设置

UITLITY.H的源文件如下:

#include <iostream.h>
#include <fstream.h>
#include <string.h>
#include <ctype.h>
#include <time.h>

enum Error_code { success, fail, range_error, underflow, overflow, fatal,
not_present, duplicate_error, entry_inserted, entry_found,
internal_error };

bool user_says_yes();

====================
UTILITY.CPP 的源文件

#include "UTILITY.H" //与头文件相连
bool user_says_yes()
{
int c;
bool initial_response = true;

do { // Loop until an appropriate input is received.
if (initial_response)
cout << " (y,n)? " << flush;

else
cout << "Respond with either y or n: " << flush;

do { // Ignore white space.
c = cin.get();
} while (c == '\n' || c ==' ' || c == '\t');
initial_response = false;
} while (c != 'y' && c != 'Y' && c != 'n' && c != 'N');
return (c == 'y' || c == 'Y');
}

===============================================
queue.h的源文件

const int maxqueue=20;

class Queue {
public:
Queue();
bool empty() const;
Error_code append(const Queue_entry &item);
Error_code retrieve(Queue_entry &item) const;
protected:
int count;
int front,rear;
Queue_entry entry[maxqueue];
};

==========================================
queue.cpp 的源文件

#include "queue.h" //与头文件相连

Queue::Queue()
/*Post:The Queue is initialized to be empty.*/
{
count=0;
rear=maxqueue-1;
front=0;
}

bool Queue::empty() const
/*Post:Return true if the Queue is empty,otherwise return false.*/
{
return count==0;
}

Error_code Queue::append(const Queue_entry &item)
/*Post: item is added to the rear if the Queue.if the Queue is full return an
Error_code of overflow and leave the Queue unchanged.*/
{
if(count>=maxqueue) return overflow;
count++;
rear=((rear+1)==maxqueue) ? 0:(rear+1);
entry[rear]=item;
return success;
}

Error_code Queue::retrieve(Queue_entry &item) const
/*Post:The front of the Queue retrieved to the output parameter item. if the
Queue is empty return an Error_code of underflow.*/
{
if(count<=0) return underflow;
item=entry[front];
return success;
}

======================
如果将主函数设置如下时,出现错误链接的信息,头文件
"UITLITY.H"总是链接不上。请帮我找找原因!!

#include "UITLITY.H" //链接UITLITY.H
typedef double Queue_entry;
#include "queue.h"

void main()
{
...........
}

搜索更多相关主题的帖子: 文件 
2006-03-08 18:31
快速回复:[讨论]关于头文件的设置
数据加载中...
 
   



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

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