C++ Programming Blog

 
 
 
//Conversion CLASS TO BASIC
//TIME CONVERSION

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

class time
{
 int hrs;
 int mins;
 public:
   time()
   {}
   void getdata()
   {
     cout<<\"Enter value for Hours  : \";
     cin>>hrs;
     cout<<\"Enter value for Minutes: \";
     cin>>mins;
   }
   void display()
   {
     cout<<\"\\n\\nHours   : \"<<hrs;
     cout<<\"\\nMinutes : \"<<mins;
   }
   operator int()
   {
     int t;
     t = hrs*60;
     t = t + mins;
     return t;
   }
};


void main()
{
  clrscr();
  time o1;
  o1.getdata();
  o1.display();

  int duration;
  duration=o1;

  cout<<\"\\nDuration : \"<<duration<<\"  minutes\";
  getch();
}

    Related Post:
  1. Program to initialize array by even numbers starting from 2 and display sum of all elements

  2. Program that take font and background color and text input from a user and display it in right aligned

  3. Program to illustrate adding values to the contents of variables whose addresses are in pointers

  4. Program to add two numbers

  5. Program to illustrate the Insertion Sort

  6. Program of class to class conversion

  7. Program of construction overloading

  8. Program that reads marks obtained by a student in a test of 100 marks and print pass if marks are greater than or equal to 50

  9. Program to illustrate the functions returning pointers

  10. Program to read decimal numbers from a file and convert into hexadecimal

  11. Program to find largest element of an array

  12. Program of time conversion using conversion functions

  13. Program that provides an example of passing objects to function using call by reference method

  14. Program to illustrate the implementation of Double Ended linked list as a Queue

  15. Program to estimate the Differential value of a given function using Trapezoidal Rule [Predictor-Corrector Scheme (PC2)]

  16. Program that performs SCANNING of the following program and finds the entire float,integer variables and keywords present in the program

  17. Program to implement the Binary search Algorithm

  18. Program that reads an expression consisting of two non-negative integer and an operator. Determine if either integer or the result of the expres......

  19. Program to draw a K-Curve of nth order

  20. Program to illustrate self-referential structures Linked List

 
 
Didn't find what you were looking for? Find more on Program to illustrate operator overloading from class to basic type