Logo 
Search:

C++ Programming Articles

Submit Article
Home » Articles » C++ Programming » Homework HelpRSS Feeds

Program of class to basic conversion

Posted By: Lorelei Schmidt     Category: C++ Programming     Views: 6336

Write a program of class to basic conversion.

Code for Program of class to basic conversion in C++ Programming

# include <iostream.h>
# include <conio.h>
# include <stdlib.h>
class date
{
    int dd,mm,yy;
    public:
    date()
    {
    }
    date(int cdd,int cmm,int cyy)
    {
        dd=cdd;
        mm=cmm;
        yy=cyy;
    }
    operatorchar *();
};

main()
{
    clrscr();
    date d1,d2;
    int cmm,cdd,cyy;
    cout<<"\nENTER THE DAY:->";
    cin>>cmm;
    cout<<"\nENTER THE MONTH:->";
    cin>>cdd;
    cout<<"\nENTER THE YEAR:->";
    cin>>cyy;
    char dt[10];
    d2.date(cdd,cmm,cyy);
    strcpy(dt,d2);
}

date::operatorchar *()
{
    char *str;
    char a[10];
    str=a;
    int i=1;
    while(1)
    {
        *str=dd/10+'0';
        str++;
        *str=dd%10+'0';
        str++;
        i++;
        if(i>3)
            break;
        *str='/';
        str++;
        if(i==2)
            dd=mm;
        else
            dd=yy;
}
}
  
Share: 


Didn't find what you were looking for? Find more on Program of class to basic conversion Or get search suggestion and latest updates.

Lorelei Schmidt
Lorelei Schmidt author of Program of class to basic conversion is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!