引用&

来源:互联网 发布:淘宝网集市商家热线 编辑:程序博客网 时间:2024/06/06 16:26

// 引用.cpp : Defines the entry point for the console application.
//

#include "StdAfx.h"
#include "iostream.h"

int main(int argc, char* argv[])
{
// printf("Hello World!\n");
 int a[3] ={1,2,0};
// a[0]=0;a[1]=1;a[2]=2;
 int *p,*q;
 p = a;
 q = &a[2];
 cout<<a[q-p]<<endl;
 return 0;
}

 //不论a[2]值如何改变,结果都为a[2];值为0;

// printf("Hello World!\n");
 int a[6] ={1,2,10,4,5,6};
// a[0]=0;a[1]=1;a[2]=2;
 int *p,*q;
 p = a;
 q = &a[2];
 cout<<a[q-p]<<endl;
 return 0;
}

//值为10;

P =A ;和A[Q-P]  这儿还有点疑问。

 ////////////////////////////////

 int a[] = {1,2,3,4,5};
/* int i;
 for (i=0;i<=4;i++)
 {
  cout<<a<<endl;
 }
 */
 int *i ;
 i = a;
 for (int b=0;b<=4;b++)
 {
 
 cout<<*i<<endl;
 }
 return 0;
 }

输出值为1 1 1 1 1

//////////////////////////////////

原创粉丝点击