L
Latina
Hi, I am doing a program that deals with dates, so the program needs
to check if the user enters the date with numbers or letters.
I try isAlpha() and isAlnum() but it is given me an error message.
Can some one help me please.
Error:
'class Date' has no member named 'isAlpha'
'class Date' has no member named 'isAlnum'
Here is my code:
class Date
{
friend istream &operator>>(istream&, Date &);
friend ostream &operator<<(ostream&, const Date &);
private:
int mon,day,year;
public:
Date(){mon=day=year=0;}
int operator-(const Date&)const;
void print();
};
istream& operator>>(istream &in, Date &d)
{
if(d.isAlpha())
{
in>>d.mon;
in>>d.day;
in.ignore(1); //skip the ","
in>>d.year;
}
if(d.isAlnum())
{
in>>d.mon;
in.ignore(1); //skip the "/"
in>>d.day;
in.ignore(1); //skip the "/"
in>>d.year;
}
return in;
}
Thanks
to check if the user enters the date with numbers or letters.
I try isAlpha() and isAlnum() but it is given me an error message.
Can some one help me please.
Error:
'class Date' has no member named 'isAlpha'
'class Date' has no member named 'isAlnum'
Here is my code:
class Date
{
friend istream &operator>>(istream&, Date &);
friend ostream &operator<<(ostream&, const Date &);
private:
int mon,day,year;
public:
Date(){mon=day=year=0;}
int operator-(const Date&)const;
void print();
};
istream& operator>>(istream &in, Date &d)
{
if(d.isAlpha())
{
in>>d.mon;
in>>d.day;
in.ignore(1); //skip the ","
in>>d.year;
}
if(d.isAlnum())
{
in>>d.mon;
in.ignore(1); //skip the "/"
in>>d.day;
in.ignore(1); //skip the "/"
in>>d.year;
}
return in;
}
Thanks