请扶新手上路:编译问题

haaa 2002-01-18 10:50:10
我是c++的新手(既菜鸟),一本<<c++大学教程>>(第2版)看了三个月还不知所云,以后少不得麻烦大家,在此先行谢过.下面这问题我就不得其解:
#ifndef TIME1_H
#define TIME1_H
class Time{
public:
Time();
....
private:
...
};
#endif
------------------
#include<iostream.h>
#include "time1.h"
Time::Time() {hour= minute = second =0; }
........
----------------
#include<iostream.h>
#include "time1.h"

int main()
{
Time t;
.....
.....
return 0;
}
(可参考原书fig 06_05)
编译时,总是出现如下提示:
fatal error C1083: Cannot open include file: 'time1.h': No such file or directory
Error executing cl.exe.
不知是什末原因,我是在vc++里编译的,步骤是在vc++里"文件"->"新建"->"文件"(而不是"工程")->"c++ source file"最后再编译既出现上述问题的.另希望看过此书的人能对其做出评价。

...全文
61 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
haaa 2002-01-19
  • 打赏
  • 举报
回复
to:scklotz(晓春)
注意你的程序几个文件组成,不是一个文件
那如何编译呢?
敬请指教。
kingfish 2002-01-18
  • 打赏
  • 举报
回复
先看看你工程所在目录下有无此文件
leizhengdeng 2002-01-18
  • 打赏
  • 举报
回复
add to project->files-> 'time1.h'
zhangroc 2002-01-18
  • 打赏
  • 举报
回复
书不好
用<<C++程序设计教程>>
钱能编的不错。
给一点分,还要更好的告诉你。
scklotz 2002-01-18
  • 打赏
  • 举报
回复
ifndef TIME1_H
#define TIME1_H
class Time{
public:
Time();
....
private:
...
};
#endif
//------------------ 以上是time1.h文件
#include<iostream.h>
#include "time1.h"
Time::Time() {hour= minute = second =0; }
........
//---------------- 以上是 time1.cpp文件
#include<iostream.h>
#include "time1.h"

int main()
{
Time t;
.....
.....
return 0;
}
////////// 以上是 main.cpp 文件。

注意你的程序几个文件组成,不是一个文件。

69,382

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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