主题:刚学C++,很多错误都不会改,拜求高手帮忙!!!!
include <iostream>
using namespace std;
class month
{
public:
month(int m);
month(char a,char b,char c);
month();
void intger_input(istream& ins);
void letter_input(istream& ins);
void intger_output(ostream& outs);
void letter_output(ostream& outs);
month next();
private:
int m;
char a, b, c;
};
int main()
{
month t,n;
cout<<"please input month using intger:";
t.intger_input(cin);
t.intger_output(cout);
cout<<"please iuput month using letter:";
n.letter_input(cin);
n.letter_output(cout);
cout<<"next month is:";
month next();
return 0;
}
month::month(int m)
{
if(m>12||m<1)
exit(1);
}
month::month(char a,char b,char c)
{
if(!(isalpha(a)&&isalpha(b)&&isalpha(c)))
exit(1);
}
month::month():m(0),a(0),b(0),c(0)
{
}
void month::intger_input(istream& ins)
{
ins>>m;
}
void month::letter_input(istream& ins)
{
ins>>a>>b
>>c>>endl;
}
void month::intger_output(ostream& outs)
{
outs<<m;
}
void month::letter_outpit(ostream& outs)
{
outs<<a<<b
<<c<<endl;
}
month::next()
{
month next_month;
next_month=m+1;
return next_month;
}
附:month::next()
{
month next_month;
next_month=m+1;
return next_month;
}
这个函数是要求把下个月作为month类型的一个值返回,不知道是不是这样做。。。
using namespace std;
class month
{
public:
month(int m);
month(char a,char b,char c);
month();
void intger_input(istream& ins);
void letter_input(istream& ins);
void intger_output(ostream& outs);
void letter_output(ostream& outs);
month next();
private:
int m;
char a, b, c;
};
int main()
{
month t,n;
cout<<"please input month using intger:";
t.intger_input(cin);
t.intger_output(cout);
cout<<"please iuput month using letter:";
n.letter_input(cin);
n.letter_output(cout);
cout<<"next month is:";
month next();
return 0;
}
month::month(int m)
{
if(m>12||m<1)
exit(1);
}
month::month(char a,char b,char c)
{
if(!(isalpha(a)&&isalpha(b)&&isalpha(c)))
exit(1);
}
month::month():m(0),a(0),b(0),c(0)
{
}
void month::intger_input(istream& ins)
{
ins>>m;
}
void month::letter_input(istream& ins)
{
ins>>a>>b
>>c>>endl;
}
void month::intger_output(ostream& outs)
{
outs<<m;
}
void month::letter_outpit(ostream& outs)
{
outs<<a<<b
<<c<<endl;
}
month::next()
{
month next_month;
next_month=m+1;
return next_month;
}
附:month::next()
{
month next_month;
next_month=m+1;
return next_month;
}
这个函数是要求把下个月作为month类型的一个值返回,不知道是不是这样做。。。