内容:

说明:
指针作为C++的一个精髓,是必须要掌握的~
传参的时候只有通过指针才能改变源的值
完成函数:传入两个整数的指针,返回两数之和和两数绝对值
示例代码:
// Pointer.cpp: 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
using namespace std;
void update( int *a, int *b )
{
*a = *a + *b;
*b = abs( *a - *b - *b );
}
//by zhaocl
int main()
{
int a, b;
cin >> a >> b;
//if use a and b as argument,a and b not change,so we must use their pointer
update( &a, &b );
cout << a << endl;
cout << b << endl;
system( "pause" );
return 0;
}
知识点:
指针的基本使用

7818

被折叠的 条评论
为什么被折叠?



