void calculata ()
cout << "This is a program that performs addition, subtraction, multiplication and division\n\n";
cout << "Input an equation (e.g 1+2)\n\n";
cin >> numberOne >> Operaor >> numberTwo;
result = numberOne + numberTwo;
cout << numberOne << "+" << numberTwo << "is: " << result << endl;
result = numberOne - numberTwo;
cout << numberOne << "-" << numberTwo << "is: " << result << endl;;
result = numberOne * numberTwo;
cout << numberOne << "*" << numberTwo << "is: " << result << endl;
result = numberOne / numberTwo;
cout << numberOne << "/" << numberTwo << "is: " << result << endl;
The log says:
||=== Build: Debug in fred (compiler: GNU GCC Compiler) ===|
C:\Users\Ken\Documents\C++\fred\main.cpp||In function 'void calculata()':|
C:\Users\Ken\Documents\C++\fred\main.cpp|16|error: invalid conversion from 'const char*' to 'int' [-fpermissive]|
C:\Users\Ken\Documents\C++\fred\main.cpp|16|error: conversion from pointer type 'const char (*)' to arithmetic type 'int' in a constant-expression|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
@Ostrich, fundamentally it's good code. Your error messages are telling you that you can't convert from a const char* (something enclosed in " ") to an integer (as required by a switch statement). As @UK Marine pointed out, change the double quotes to single quotes (' ') indicating a char and make this the type of Operator (char is a low-byte representation of an integer).
Maybe also consider rearranging the code where you see what is (nearly) the same line appearing four times.
It isn't necessary to return anything explicitly from main unless you plan to interact with the operating system; it will return 0 automatically.
Sorry for my previous comment, just realized how pointless it was...
btw I think Uk Marine was trying to show you a more cleaner implementation of your code (I think). For example, this is optional, but I think it's good practice to always initialize your variables because when they're not initialized then their values are indeterminate and you cannot rely on them being anything as the standard does not define them. Even statically allocated variables should be initialized. So if you want, you could initialize your variables and avoid a potential headache in the future. There is no good reason to not initialize a variable, plenty of good reasons to do the opposite. And enumerations are very good and I highly encourage you to use them when you have different operations and events to choose from, it makes your code slightly more readable. Like I can look at uk marine's enum and immediately understand what the whole thing is doing without having to look at the cases.. just an example.
Nonetheless, your calculator looks good, good job man =)