online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> using namespace std; class Time { private: int second; int minute; public: int getSecond() { return second; } int getMinute() { return minute; } Time():minute(0),second(0) {} Time(int m,int s):minute(m),second(s) {} Time(int s):second(s) {} void outPut(); Time operator +(Time &anotherTime); }; void Time::outPut() { cout << minute << " minute(s) " << second << "second(s)" << endl; } Time Time::operator +(Time &anotherTime) { int allSecond = second + anotherTime.second; int allMinute = minute + anotherTime.minute; if(allSecond >= 60) { allMinute += allSecond / 60; allSecond = allSecond % 60; } return Time(allMinute,allSecond); } int main() { Time time1(5,30),time2(1,3),time3; time3 = time1 + time2; time3.outPut(); return 0; }
#include <iostream> #include "Time.h" using namespace std; int main() { Time time1(5,30),time2(1,32),time3; time3 = time1 + time2; // call member function time3.outPut(); int time4 = 5; time3 = time4 + time1; // call friend function time3.outPut(); return 0; }
class Time { private: int second; int minute; public: int getSecond() { return second; } int getMinute() { return minute; } Time():minute(0),second(0) {} Time(int m,int s):minute(m),second(s) {} Time(int s):second(s) {} void outPut(); Time operator +(Time &anotherTime); // time + time friend Time operator+(int &second,Time &anotherTime); // int + time };
#include "Time.h" #include <iostream> using namespace std; Time Time::operator +(Time &anotherTime) { int allSecond = second + anotherTime.getSecond(); int allMinute = minute + anotherTime.getMinute(); if(allSecond >= 60) { allMinute += allSecond / 60; allSecond = allSecond % 60; } return Time(allMinute,allSecond); } void Time::outPut() { cout << minute << " minute(s) " << second << "second(s)" << endl; } Time operator+(int &second,Time &anotherTime) { int allSecond = second + anotherTime.getSecond(); int allMinute = anotherTime.getMinute(); if(allSecond >= 60) { allMinute += allSecond / 60; allSecond = allSecond % 60; } return Time(allMinute,allSecond); }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue