#include "stdafx.h"
#include<iostream>
using namespace std;
void func(int *x, int *y) {
*x += 1;
*y += 1;
cout << *x << endl;
}
int main()
{
int a = 1;
int b = 12;
int *p = &a;
int *q = &b;
func(p, q);
cout << "a=" << a << " " << "b=" << b << endl;
}
指针和引用都会改变传入参数原本的值。
最新推荐文章于 2023-04-19 18:10:52 发布