免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1270 | 回复: 3
打印 上一主题 下一主题

关于连接.h文件的问题!!! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-09-27 21:49 |只看该作者 |倒序浏览
///////cout.h
void ct ()
{

cout<<"why I am wrong!";

}
//////////////main.cpp
#include"iostream.h"
#include"cout.h"
void main()
{
ct();
}
在C++编译器中会出现问题,实在不解,请各位指教!!  谢谢!

论坛徽章:
0
2 [报告]
发表于 2004-09-27 21:53 |只看该作者

关于连接.h文件的问题!!!

函数的定义需要写在.c .cpp里面
.h里面只写出函数的声明

论坛徽章:
0
3 [报告]
发表于 2004-09-27 22:14 |只看该作者

关于连接.h文件的问题!!!

我又这样编了一个程序,为什么会出错呢????
/////stack.h
enum error_code
{
sucess overflow underflow
}

typedef int stack_entry;
const int maxstack=10;
class stack
{
public:
        bool empty() const;
        error_code push(const stack_entry&item);
        errer_code pop();
        error_code top(stack_entry&item) const;
private:
        int count;
        stack_entry entry[maxstack];
}
///////////////define.cpp
bool stack::empty() const
{
bool outcome=true;
if(count>;0) outcome=false;
ruturn outcome;
}////////////////////////////////
error_code stack::pop()
{ error_code outcome=success;
  if(count<0) outcome=underflow;
  else
          --count;
          ruturn outcome;
}////////////////////////////
error_code stack::push(const stack_entry&item)
{error_code outcome=success;
if(count>;=maxstack) outcome=overflow;
else entry[count++]=item;
ruturn outcome;
}//////////////////////////////
error_code stack::top(stack_entry &item) const
{
error_code outcome=success;
if(count==0) outcome=underflow;
else item=entry[count-1];
return outcome;

////////////////reverse.cpp

#include<stack.h>;
#include<iostream.h>;
void main()
{
stack j;
int i,k;
cin>;>;i;
for(int n=0,n<i,i++)
{
cin>;>;k;
j.push(k);
}
while(!j.empty())
{
cout<<j.top();
j.pop();
}

}

这个程序只要是用栈实现一个倒序输出,运行时只有一个错误.如下:
fatal error C1083: Cannot open include file: 'stack.h': No such file or directory
请各位指教!!!谢谢

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
4 [报告]
发表于 2004-09-27 22:24 |只看该作者

关于连接.h文件的问题!!!

#include   "stack.h"
试试。
以后贴代码用code功能。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP