online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <iostream> struct Date { //always always initialize built in type in block/local scope int date = 0, month = 0, year = 0; // by default public //default constructor Date() = default; //lets overload operator= for comparing two Date types as you desire friend bool operator==(const Date &lhs, const Date &rhs); friend bool operator!=(const Date &lhs, const Date &rhs); //overload operator>> for taking input from user friend std::istream& operator>>(std::istream &is, Date &rhs); }; bool operator==(const Date &lhs, const Date &rhs) { return lhs.date == rhs.date && lhs.month == rhs.month && lhs.year == rhs.year; } bool operator!=(const Date &lhs, const Date &rhs) { return !(lhs == rhs); } std::istream& operator>>(std::istream &is, Date &rhs) { std::cout<<"Enter date: "; //take date as input from user std::cin >> rhs.date; std::cout<<"Enter month: "; //take month as input from user std::cin >> rhs.month; std::cout<<"Enter year: "; //take year as input from user std::cin >> rhs.year; //check if input succedded if(!is) { rhs = Date(); } return is; } int main() { //create first Date struct Date d1; std::cin >> d1;//take input from user //create second Date struct Date d2; std::cin >> d2;//take input from user //lets check if dates d1 and d2 entered by user are equal or not std::cout<<"The dates d1 and d2 are: "<<(d1==d2? "equal": "not equal")<<std::endl; return 0; }
this is first line second line is this one

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