简体   繁体   English

如何解释从<typeinfo>图书馆?

[英]How to interpret data types obtained from <typeinfo> library?

Q1 - Since both begin(arr) & &arr will return hexadecimal pointer location of starting of the arr , wondering what is the difference between the outputs of data types printed by the following script? Q1 -由于两个begin(arr) &arr将返回的开始的十六进制指针位置arr ,不知道是什么数据类型的由以下脚本打印的输出之间的差?

#include <iostream>
#include <typeinfo>
#include <string>

using namespace std;

int main()
{
    int arr[] = {10, 20, 30, 40, 50, 60, 77};

    cout << typeid(begin(arr)).name() << " , " << typeid(&arr).name() << endl;
    cout << begin(arr) << " , " << &arr << endl;

    return 0;
}

OUTPUT输出

Pi , PA7_i
0x7ffc79a99500 , 0x7ffc79a99500

Q2 - how can we get decimal representation of hex pointer location? Q2 - 我们如何获得十六进制指针位置的十进制表示?

For Q1:对于第一季度:

Note that begin(arr) and &arr are different things (with different types).请注意begin(arr)&arr是不同的东西(具有不同的类型)。 begin(arr) gives the pointer to the 1st element of arr with type int* , &arr gives the pointer to the array arr with type int (*)[7] . begin(arr)给出了指针的第一元件arr类型int*&arr给出指向数组arr类型int (*)[7]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM