C++相关知识复习摘要

 
//转自:https://www.cnblogs.com/jianfeijiang/p/5914398.html
//

using namespace std;
int main(){
    
    //a) 一个整型数( An integer)
    int a;
    //b) 一个指向整型数的指针( A pointer to an integer)
    int *b;
    //c) 一个指向指针的的指针,它指向的指针是指向一个整型数( A pointer to a pointer to an integer)
    int **c;
    //d) 一个有 10 个整型数的数组( An array of 10 integers)
    int d[10];
    //e) 一个有 10 个指针的数组,该指针是指向一个整型数的( An array of 10 pointers to integers)
    int *e[10]
    //f) 一个指向有 10 个整型数数组的指针( A pointer to an array of 10 integers)
    int (*f)[10];
    //g) 一个指向函数的指针,该函数有一个整型参数并返回一个整型数( A pointer to a functionthat takes an integer as an argument and returns an integer)
    int *g(int);
    //h) 一个有 10 个指针的数组,该指针指向一个函数,该函数有一个整型参数并返回一个整型数( An array of ten pointers to functions that take an integer argument and return an integer 
    int (*h[10])(int);
    return 0;
}

对数组名取地址,是整个数组的地址

short tell[10]={1,2,3,4,5,6,7,8,9,0};

cout<<"先打印地址值:"<<endl;
cout<< tell << " , "<<&tell[0]<<endl;
cout<< &tell << endl<<endl;

cout<<"&tell[0] = "<<&tell[0]<<endl;
cout<<"&tell[1] = "<<&tell[1]<<endl<<endl;
cout<<"&tell[10] = "<<&tell[10]<<endl<<endl;

cout<<"然后打印tell+1的地址: "<<endl;
cout<<"tell+1:  "<< tell+1<<endl;
cout<<"&tell+1: " << &tell+1 <<endl;

//比如

short (*pas)[20] = &tell;  //这里pas是指向一个数组的指针。

//*pas 与tell是等价的。  即(*pas)[0]与tell[0]等价。

 

 

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值