高校计算机

3773考试网计算机等级考试高校计算机正文

C++中双指针的作用(int**)

来源:fjzsksw.com 2009-11-3 16:02:40

 

int main(){

  int a=10;

  int *p=&a;

  cout<<&a<<endl;

  cout<<&p<<endl;

  fun1(&p);

  *p=10;

  cout<<*p<<endl;

  }

  二级指针的例子:

  #include <iostream>

  using namespace std;

  void fun2(int *p){

  cout<<*p<<endl;

  p=(int *)malloc(sizeof(int));

  *p=100;

  cout<<*p<<endl;

  }

  int main(){

  int a=10;

  int *p=&a;

  fun2(p);

  cout<<*p<<endl;}

上一页  [1] [2] 

触屏版 电脑版
3773考试网 琼ICP备12003406号-1