美文网首页
39 - Pass by Reference with Poin

39 - Pass by Reference with Poin

作者: 社交帐号直接注册 | 来源:发表于2018-01-02 10:08 被阅读0次
#include <iostream>
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 Poin

      本文链接:https://www.haomeiwen.com/subject/tskfnxtx.html