#include<iostream>
#include<string>
using namespace std;
class data
{
public:
int day;
int month;
int year;
data() //this is a default constructure
{
day=12;
month=4;
year=2020;
}
data(int x,int y)
{
day=12;
month=x;
year=y;
}
void mon()
{
if(month>=1 && month<=12)
{
month=1;
}
cout<<"month:"<<month<<endl;
}
void disply()
{
cout<<"year"<<year<<endl;
cout<<"month"<<month<<endl;
cout<<"day"<<day<<endl;
}
};
int main()
{
data n();
data d(3,2020);
d.mon();
d.disply();
}
No comments:
Post a Comment