Overloading Basic Programming Concept in C++


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

class PERIOD
{
    int days, months,years;
  public:
    void show();
    PERIOD(int d,int m,int y);
};

void PERIOD::show
{
    cout<<days<<months<<years<<endl;
}

PERIOD::PERIOD(int d,int m,int y)
{
    days=d;months=m;years=y;
}

int main () 
{
  clrscr();
  PERIOD p1(10,6,100);
  p1.show();
  PERIOD p2(p1);
  p2.show();
  getch();
  return 0;
}

No comments:

Post a Comment

Custom Search