39 - Pass by Reference with Pointers

#include 
using namespace std;

void passByValue(int x);
void passByReference(int *x);

int main()
{
    int betty = 13;
    int sandy = 13;
    passByValue(betty);
    passByReference(&sandy);
    cout << "betty is " << betty << endl;
    cout << "sandy is " << sandy << endl;
    return 0;
}

void passByValue(int x)
{
    x = 99;
}

void passByReference(int *x)
{
    *x = 66;
}

你可能感兴趣的:(39 - Pass by Reference with Pointers)