Hello.
I've been continuing trying to improve my little "calculator". It's just a basic one with addition, substraction, multiplication and division.
So far, I managed to add Addition and Substraction into one program.
Then I tried with Multiplication and Division, but the turnout weren't quite as good, as with the first one I did.
When I click compile, it gives me a lot of Linker Errors.
If anyone can help me on this one, it'd be greatly appreciated!
The program's code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
int addition(int x, int y);#include <conio.h>
#include <iostream>
#pragma hdrstop
using namespace std;
int addition (int, int);
void showResult(int);
int main(int argc, char **argv, int res)
// int main (int, char**)
{
int x, y, result;
char calcer;
cout << endl <<"Enter the first value:";
cin >> x;
cout << endl <<"Enter your calctype\n + for Addition, - for Subtraction\n* for multiplication and / for division:";
cin >> calcer;
cout <<"Enter the second value: ";
cin >> y;
int addition (int, int);
if (calcer == '+'){
result = addition(x, y);
showResult(result);
}
int subtract (int, int);
if (calcer == '-') {
result = subtract(x, y);
showResult(result);
}
int multiplication (int, int);
if (calcer == '*'){
result = multiplication(x, y);
showResult(result);
}
int dividation (int, int);
if (calcer == '/'){
result = dividation(x, y);
showResult(result);
}
else {
cout<<"Incorrect calculation type selected. Please restart the program.\n";
}
{
cout << endl << endl << "Press any key to continue...";
getch();
return 0;
}
int addition(int x, int y);
{
return x + y; //change to + - * or /.
}
int subtract(int x, int y);
{
return x - y; //change to + - * or /.
}
int multiplication(int x, int y);
{
return x * y; //change to + - * or /.
}
int dividation(int x, int y);
{
return x / y; //change to + - * or /.
}
void showResult(int res);
{
cout<<"The result is "<< res << endl;
}
}
|
The Linker Errors are following:
[Linker error] undefined reference to `addition(int, int)'
[Linker error] undefined refence to `showResult(int)'
-----------.------------------------- subtract(int, int)
-----------.------------------------- showResult(int)
-----------.------------------------- multiplication(int, int)
-----------.------------------------- showResult(int)
-----------.------------------------- dividation(int, int)
-----------.------------------------- showResult(int)
Thanks.