Calculator - C++ operator-overloading I am new to object-oriented concepts. The following is my attempt at creating a basic calculator using class and operator overloading concepts. Please review it for improvements. Also, how do I make it more intuitive? I want to display: +,-,*,/ as options and use switch on them. 

#include &lt;iostream&gt;
#include &lt;conio.h&gt;

using namespace std;

class calculator
{
    private:
        float val;

    public:
        calculator(): val(0)
        {}

        void getdata()
        {           
            cout &lt;&lt; "enter number: ";
            cin &gt;&gt; val;
        }

        void showdata()
        {
            cout &lt;&lt; "value: " &lt;&lt; val &lt;&lt; endl;
        }

        calculator operator + (calculator) const;
        calculator operator - (calculator) const;
        calculator operator * (calculator) const;
        calculator operator / (calculator) const;
};

calculator calculator::operator + (calculator arg2) const
{
    calculator temp;
    temp.val = val + arg2.val;
    return temp;
}

calculator calculator::operator - (calculator arg2) const
{
    calculator temp;
    temp.val = val - arg2.val;
    return temp;
}

calculator calculator::operator * (calculator arg2) const
{
    calculator temp;
    temp.val = val * arg2.val;
    return temp;
}

calculator calculator::operator / (calculator arg2) const
{
    calculator temp;
    temp.val = val / arg2.val;
    return temp;
}

void main()
{
    calculator obj1, obj2, obj3;
    char ch;
    int choice;

    obj1.getdata();
    cout &lt;&lt; "1st value entered: ";
    obj1.showdata();
    cout &lt;&lt; endl;

    obj2.getdata();
    cout &lt;&lt; "2nd value entered: ";
    obj2.showdata();
    cout &lt;&lt; endl;

    cout &lt;&lt; "Input choice as integer: 1: +,   2: -,   3: *,   4:/     ";
    cin &gt;&gt; choice;
    cout &lt;&lt; endl;

    switch (choice)
    {
        case 1:
            obj3 = obj1 + obj2;
            break;
        case 2:
            obj3 = obj1 - obj2;
            break;
        case 3:
            obj3 = obj1 * obj2;
            break;
        case 4:
            obj3 = obj1 / obj2;
            break;
        default:
            cout &lt;&lt; "Invalid choice! " &lt;&lt; endl;
    }

    cout &lt;&lt; "Result ";
    obj3.showdata();
    cout &lt;&lt; endl;

}
You can also overload operator&gt;&gt; instead of using getdata():

std::istream&amp; operator&gt;&gt;(std::istream&amp; in, calculator&amp; obj)
{
    return in &gt;&gt; obj.val;
}


Similar approach with showdata(), using operator&lt;&lt;:

std::ostream&amp; operator&lt;&lt;(std::ostream&amp; out, calculator const&amp; obj)
{
    return out &lt;&lt; "value: " &lt;&lt; obj.val;
}


As for your existing overloads, you shouldn't need to return a calculator.  You appear to treat each calculator object as a single value.  This makes each one to appear to be single-use, and the more values you wish to enter, the more objects thus the more code you'll need to have.

What you should do is maintain one object and have val maintained as you enter data.  However, this will also mean that your arithmetic operators aren't needed.  If you wish to keep them, then you'll have to approach this differently.  For instance, you can calculate (not merely input) a final value for different calculators and use those operators to get a new value.  This may look like a needless approach for a simple calculator, but at least you're still able to utilize these arithmetic operators.

Some miscellaneous notes:


Be aware of the issues of using using namespace std.
You don't appear to be using &lt;conio.h&gt;, so just remove it.
You don't need to use std::endl in so many places.  A simple "\n" for outputting a newline should be sufficient.  More info about that here.