| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 736 人关注过本帖
标题:书上没说清楚,求指教错误
只看楼主 加入收藏
原味好
Rank: 4
来 自:西安
等 级:业余侠客
帖 子:59
专家分:250
注 册:2011-11-29
结帖率:80%
收藏
已结贴  问题点数:20 回复次数:4 
书上没说清楚,求指教错误
编程环境:visual c++ 6.0
两个文件为什么连不起来??
程序代码:
文件1
# include<iostream.h>
# include"tdate.h"

void main()
{
    Tdate s;
    s.Set(12/9/2011);
    someFunc(&s);
}
void someFunc(Tdate * pS)
{
    pS->Print();
    if (pS->IsLeapYear())
        cout<<"ohoh\n";
    else
        cout<<"right\n";
}
文件2
# include<iostream.h>
class Tdate
{
public:
    void Set(int m,int d,int y)
    {
        month=m;
        day=d;
        year=y;
    }
    int IsLeapYear()
    {
        return (year%4==0&&year%100!=0)||(year%400==0);
    }
    void Print()
    {
        cout<<month<<"/"<<day<<"/"<<year<<"\n";
    }
private:
    int month;
    int day;
    int year;
};   
错误提示:
C:\Users\Administrator\Desktop\c++\2.cpp(2) : fatal error C1083: Cannot open include file: 'tdate.h': No such file or directory
搜索更多相关主题的帖子: 编程 visual color 
2011-12-09 19:33
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9007
专家分:53942
注 册:2011-1-18
收藏
得分:7 
错误提示已经非常直白明了了
2011-12-10 08:16
共和国鹰派
Rank: 3Rank: 3
来 自:山东
等 级:论坛游侠
帖 子:37
专家分:119
注 册:2011-10-20
收藏
得分:7 
第二个文件你是命名为tdate.h的吗?并且你的代码中也有错误啊,cout没有加上命名空间啊
2011-12-10 17:48
lonely_21
Rank: 5Rank: 5
等 级:职业侠客
威 望:3
帖 子:108
专家分:395
注 册:2011-11-13
收藏
得分:7 
主函数中调用void someFunc(Tdate * pS)时要在调用之前声明
主函数中s.Set(12/9/2011);应写成s.Set(12,9,2011);
2011-12-11 00:26
wsgzg
Rank: 2
等 级:论坛游民
帖 子:10
专家分:20
注 册:2011-11-30
收藏
得分:0 
“tdate.h”是楼主自己写的头文件吧!需要设置编译器环境。。。
2011-12-22 22:13
快速回复:书上没说清楚,求指教错误
数据加载中...
 
   



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

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