Calculator with four arithmetic operations #include &lt;iostream&gt;

using namespace std;

class Math
{
private:
    int answer;
public:
    /*void getAn()
    {
        cout &lt;&lt; answer;
    }*/
    int add(int x, int y)
{
    cout &lt;&lt; "Add two numbers:\n";
    cin &gt;&gt; x;
    cin &gt;&gt; y;
    answer = x + y;
    return answer;
}
    int sub(int x, int y)
{
    cout &lt;&lt; "Subtract one number from the other:\n";
    cin &gt;&gt; x;
    cin &gt;&gt; y;
    answer = x - y;
    return answer;
}
    int multi(int x, int y)
{
    cout &lt;&lt; "Multiply two numbers:\n";
    cin &gt;&gt; x;
    cin &gt;&gt; y;
    answer = x * y;
    return answer;
}
    int divi(int x, int y)
{
    cout &lt;&lt; "Divide two numbers:\n";
    cin &gt;&gt; x;
    cin &gt;&gt; y;
    answer = x / y;
    return answer;
}
};

int main()
{
    int choice;
    int x,y;
    int learning = 1;
    Math doMath;
    cout &lt;&lt; "This is a calculator!\n" &lt;&lt; endl;
    while(learning==1)
    {
        //doMath.getAn();
        cout &lt;&lt; endl;
        cout &lt;&lt; "Menu:\n1) Addition\n2) Subtraction\n3) Multiplication\n4) Division\n5) Quit\n" &lt;&lt; endl;
        cout &lt;&lt; "Choose your option.\n";
        cin &gt;&gt; choice;
        if(choice==1)
        {
            cout &lt;&lt; doMath.add(x,y) &lt;&lt; endl;
        }else if(choice==2)
        {
            cout &lt;&lt; doMath.sub(x,y) &lt;&lt; endl;
        }else if(choice==3)
        {
            cout &lt;&lt; doMath.multi(x,y) &lt;&lt; endl;
        }else if(choice==4)
        {
            cout &lt;&lt; doMath.divi(x,y) &lt;&lt; endl;
        }else if(choice==5)
        {
            learning = 0;
        }else
        {
            cout &lt;&lt; "THAT WASN'T A CHOICE, YOU LITTLE SHIT!!!" &lt;&lt; endl;
            learning = 0;
        }
    }
    return 0;
}
Do not insult users

"THAT WASN'T A CHOICE, YOU LITTLE SHIT!!!" is absolutely not acceptable.


You are repeating yourself a lot, in programming you should avoid as much as possible code repetition as it leads to bugs and is not easily reusable.

Instead do this:

template&lt;typename Function&gt;
int do_operation(int x, int y,Function operation,string message) {
    cout &lt;&lt; message
    cin &gt;&gt; x;
    cin &gt;&gt; y;
    answer = operation(x,y);
    return answer;
}


You can then do:

int add(int x,int y) {
    return do_operation(x, y, std::plus&lt;int&gt;(), "Add two numbers:\n");
}

I see many many if and elif, it is better to use a switch statement. You may even use an array but perhaps then it would be overkill.
learning is quite puzzling as a name. A more standard running is more intuitive.
//doMath.getAn(); and 

/*void getAn()
{
    cout &lt;&lt; answer;
}*/


are really puzzling. Either uncomment them or delete them because commented out code confuses the readers.
Use constants for your strings and put them at the top. You can modify them in a simpler and faster way.

static const string Menu = "Menu:\n1) Addition\n2) Subtraction\n3) Multiplication\n4) Division\n5) Quit\n"
static const string ErrorMessage = "Invalid choice, enter a valid number."


and then

cout &lt;&lt; Menu &lt;&lt; endl;
cout &lt;&lt; "Choose your option.\n";


and 

else {
    cout &lt;&lt; ErrorMessage &lt;&lt; endl;
    running = 0;
}

Do not use while(learning==1) because it is redundant and weird, use the simpler while(learning) (or even better while(running))
Do not use using namespace std;, if you are curious to know why, look here
Put the first brace on the same line of the function title and indent the function body.

int add(int x, int y) {
    cout &lt;&lt; "Add two numbers:\n";
    cin &gt;&gt; x;
    cin &gt;&gt; y;
    answer = x + y;
    return answer;
}