Logo 
Search:

C++ Programming Articles

Submit Article
Home » Articles » C++ Programming » Object Oriented ProgrammingRSS Feeds

PROGRAM OF BASIC TO CLASS CONVERSION

Posted By: Isabella Campbell     Category: C++ Programming     Views: 6843

WRITE A PROGRAM OF BASIC TO CLASS CONVERSION.

Code for PROGRAM OF BASIC TO CLASS CONVERSION in C++ Programming

# include <iostream.h>
# include <conio.h>
# include <stdlib.h>

class date
{
    int mm,dd,yy;
    public:
    date()
    {
    }
    date(char dt[])
    {
        dd=getdt(dt,0);
        mm=getdt(dt,3);
        yy=getdt(dt,6);
    }

    int getdt(char *,int);
    void display();
};

main()
{
date d1;
char dt[10];
clrscr();
cout<<"ENTER THE DATE IN DD/MM/YY FORMAT:->";
cin>>dt;
d1=date(dt);
d1.display();
}

int date::getdt(char dt[],int i)
{
    char temp[2];
    temp[0]=dt[i];
    temp[1]=dt[i+1];
    temp[2]='\0';
    return atoi (temp);
}
void date::display()
{
    cout<<"DAY= "<<dd<<endl;
    cout<<"\nMONTH= "<<mm<<endl;
    cout<<"\nYEAR= "<<yy<<endl;
}
  
Share: 


Didn't find what you were looking for? Find more on PROGRAM OF BASIC TO CLASS CONVERSION Or get search suggestion and latest updates.

Isabella Campbell
Isabella Campbell author of PROGRAM OF BASIC TO CLASS CONVERSION is from Toronto, Canada.
 
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!