The main thing that is affecting your program is variable scope.
When you write variables in your program, the location that you write them is very important.
In your code, you have "int a = 0;" outside of your methods. This means that they are "global" variables and can be accessed from any method. That is the reason that your code works right now. You are not actually passing the variables to your method at all.
In order to pass by pointer, you need to add "&" after the variable type, like in the example given be the person before me.
Global variables have their place, but try to keep variable declarations inside methods if possible. It makes programs much easier to follow.
Like this.
CODE
#include <iostream>
using namespace std;
int add(int& a, int& b);
int main()
{
int a=0;
int b=0;
cout << "enter two numbers to be added"<<endl;
cin >> a >> b;
sum = add(a, b);
cout << a << " plus " << b << "=" << sum << endl;
return 0;
}
int add(int& a, int& b)
{
int sum=a+b;
a++;
b++;
return sum;
}
What are the "a++" and "b++" for?