c++的键盘输入问题

来源:百度知道 编辑:UC知道 时间:2024/05/12 04:09:32
# include <iostream.h>
class A{
public:
void setdate(int y=2008 ,int m=1,int d=1);
void showdate();
private:
int year,month,day;
};
void A::setdate(int y,int m,int d)
{
year=y;
month=m;
day=d;
}
inline void A::showdate()
{
cout<<year<<"."<<month<<"."<<day<<"."<<endl;
}
void main()
{int b,c,e;
A a;
a.setdate(2008,8,8);
a.showdate ();
//cout<<"请输入年月日:";
//a.setdate ();
//cin>>b>>c>>e;
//a.showdate();
}

//程序中有两句调换以后就可以了:要先读入需要的值,然后用其设置日期(setdate函数),最后显示。

# include <iostream.h>
class A{
public:
void setdate(int y=2008 ,int m=1,int d=1);
void showdate();
private:
int year,month,day;
};
void A::setdate(int y,int m,int d)
{
year=y;
month=m;
day=d;
}
inline void A::showdate()
{
cout<<year<<"."<<month<<"."<<day<<"."<<endl;
}
void main()
{int b,c,e;
A a;
a.setdate(2008,8,8);
a.showdate ();
cout<<"请输入年月日:";

//下面两句调换以后就可以了:要先读入需要的值,然后用其设置日期(setdate函数),最后显示。
cin>>b>>c>>e;
a.setdate (b , c, e);

a.showdate();
}