| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 441 人关注过本帖
标题:[求助]修改个程序
只看楼主 加入收藏
ilovey4
Rank: 1
等 级:新手上路
帖 子:65
专家分:0
注 册:2007-6-21
收藏
 问题点数:0 回复次数:6 
[求助]修改个程序

郁闷了,小弟菜鸟一个,弄了一中午到最后一调还是两个错误.大家看下帮忙纠正下:
#include <iostream.h>
using namespace std;
class Tdate{
public:
void Set(int,int,int); //成员函数声明
void Print();
friend class Pdate;
private:
int month;
int day;
int year;
};
class Pdate:public Tdate{
public:
void set1(int,int,int,int,int);
void print1();
void print2();
private:
int month1;
int day1;
int year1;
};
void Tdate::Set(int x,int y,int z)
{
day=x; month=y; year=z;
}

void Tdate::Print()
{
cout<<"输出当前日期"<<endl;
cout <<day <<"/" <<month <<"/" <<year <<endl;
}
void Pdate::set1(int m,int n,int c,int d,int u)
{
int q;
cin>>q;
m=(25+q)/30;
n=(25+q)%30;
c=(6+m)/12;
d=(6+m)%12;
u=2007+c;
u=year1;
d=month1;
n=day1;
}
void Pdate::print1()
{
cout<<"请输入所要增加的天数"<<endl;
}

void Pdate::print2()
{
cout<<"增加天数后的日期"<<endl;
cout <<day1 <<"/" <<month1 <<"/" <<year1<<endl;
}
int main()
{
Tdate a;
a.Set(25,6,2007);
a.Print();
Pdate f;
f.print1();
f.set1();
f.print2();
}
到目前有两个错误,一个是no matching function for
call to `Pdate::set1()'
另一个是candidates are: void
Pdate::set1(int, int, int, int, int)
小弟我愚昧,实在看不出来,大哥们帮忙
我的程序编的也很烂  有什么需要修改的地方  告诉一下

搜索更多相关主题的帖子: private include public friend 
2007-06-25 16:28
yuyunliuhen
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:1435
专家分:0
注 册:2005-12-12
收藏
得分:0 

[CODE]
#include <iostream> //#include <iostream.h>是旧的C++标准,如果是这个,就不需要using namespace std;
using namespace std;
class Tdate{
public:
void Set(int,int,int); //成员函数声明
void Print();
friend class Pdate;
private:
int month;
int day;
int year;
};
class Pdate:public Tdate{
public:
void set1(int,int,int,int,int);
void print1();
void print2();
private:
int month1;
int day1;
int year1;
};
void Tdate::Set(int x,int y,int z)
{
day=x; month=y; year=z;
}

void Tdate::Print()
{
cout<<"输出当前日期"<<endl;
cout <<day <<"/" <<month <<"/" <<year <<endl;
}
void Pdate::set1(int m,int n,int c,int d,int u)
{
int q;
cin>>q;
m=(25+q)/30;
n=(25+q)%30;
c=(6+m)/12;
d=(6+m)%12;
u=2007+c;
u=year1;
d=month1;
n=day1;
}
void Pdate::print1()
{
cout<<"请输入所要增加的天数"<<endl;
}

void Pdate::print2()
{
cout<<"增加天数后的日期"<<endl;
cout <<day1 <<"/" <<month1 <<"/" <<year1<<endl;
}
int main()
{
Tdate a;
a.Set(25,6,2007);
a.Print();
Pdate f;
f.print1();
//f.set1(); //没传参数呢 set1(int m,int n,int c,int d,int u)

f.print2();
}


[/CODE]


Go confidently in the  directions of your dreams,live the life you have imagined!Just do it!
It is no use learning without thinking!
2007-06-25 16:46
ilovey4
Rank: 1
等 级:新手上路
帖 子:65
专家分:0
注 册:2007-6-21
收藏
得分:0 
帮我传下参数我弄不成

新手!
2007-06-25 17:09
yuyunliuhen
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:1435
专家分:0
注 册:2005-12-12
收藏
得分:0 


#include <iostream>
using namespace std;
class Tdate{
public:
void Set(int,int,int); //成员函数声明
void Print();
friend class Pdate; //
private:
int month;
int day;
int year;
};
class Pdate:public Tdate{
public:
void set1(int,int,int,int,int);
void print1();
void print2();
private:
int month1;
int day1;
int year1;
};
void Tdate::Set(int x,int y,int z)
{
day=x; month=y; year=z;
}

void Tdate::Print()
{
cout<<"输出当前日期"<<endl;
cout <<day <<"/" <<month <<"/" <<year <<endl;
}
void Pdate::set1(int m=0,int n=0,int c=0,int d=0,int u=0)//初始化
{
int q;
cin>>q;
m=(25+q)/30; //一个月这么能都按30天算呢 ^_^
n=(25+q)%30;
c=(6+m)/12;
d=(6+m)%12;
u=2007+c;
year1=u; //u=year1;?
month1=d; //
day1=n; //
}
void Pdate::print1()
{
cout<<"请输入所要增加的天数"<<endl;
}

void Pdate::print2()
{
cout<<"增加天数后的日期"<<endl;
cout <<day1 <<"/" <<month1 <<"/" <<year1<<endl;
}
int main()
{
Tdate a;
a.Set(25,6,2007);
a.Print();
Pdate f;
f.print1();
f.set1();
f.print2();
system("pause");
}


[此贴子已经被作者于2007-6-25 17:49:24编辑过]


Go confidently in the  directions of your dreams,live the life you have imagined!Just do it!
It is no use learning without thinking!
2007-06-25 17:45
ilovey4
Rank: 1
等 级:新手上路
帖 子:65
专家分:0
注 册:2007-6-21
收藏
得分:0 
OK  谢谢了 

新手!
2007-06-25 17:57
ilovey4
Rank: 1
等 级:新手上路
帖 子:65
专家分:0
注 册:2007-6-21
收藏
得分:0 
再问下   是不是不把参数初始化就传不了参吗

新手!
2007-06-25 18:04
aipb2007
Rank: 8Rank: 8
来 自:CQU
等 级:贵宾
威 望:40
帖 子:2879
专家分:7
注 册:2007-3-18
收藏
得分:0 
以下是引用ilovey4在2007-6-25 18:04:08的发言:
再问下   是不是不把参数初始化就传不了参吗

那不是初始化,只是给要传参数一个默认值(你不设置,就按该默认值)
同样可以自己传参数。


Fight  to win  or  die...
2007-06-25 18:41
快速回复:[求助]修改个程序
数据加载中...
 
   



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

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