All about programming in GNU/LINUX

Overloaded Constructor

#include<iostream>
#include<cstdio>
using namespace std;
class date
{
int day,month,year;
public:
date(char *iamastar);
date(int d,int m,int y);
void display();
};
date::date(char *iamastar)
{
sscanf(iamastar,”%d%*c%*c%*c%*c%d%*c%*c%*c%*c%d”,&day,&month,&year);

}
date::date(int d,int m,int y)
{
day=d;
month=m;
year=y;
}
void date::display()
{
cout<<day<<“/”<<month<<“/”<<year<<“\n”;
if(day==15&&month==8&&year==1947)
cout<<“*********”<<“HAPPY INDEPENDENCE DAY <<<<<<<<<<<<<<“<<“\n”<<“JAI HIND”;
}
int main()
{
date rao1(20,9,1991),rao2(“15hack8hack1947”);

rao1.display();
rao2.display();
return 0;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s