要访问short**指向的short数组,您需要使用双重指针的解引用运算符。以下是一个示例:

#include <iostream>

int main() {
    short** arr = new short*[5]; // 创建一个short**指针,指向short*指针数组

    // 为每个short*指针分配内存,并将其指向一个short数组
    for (int i = 0; i < 5; i++) {
        arr[i] = new short[3];
        for (int j = 0; j < 3; j++) {
            arr[i][j] = i * j;
        }
    }

    // 访问short**指针指向的short数组
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < 3; j++) {
            std::cout << arr[i][j] << " ";
        }
        std::cout << std::endl;
    }

    // 释放内存
    for (int i = 0; i < 5; i++) {
        delete[] arr[i];
    }
    delete[] arr;

    return 0;
}

在上面的示例中,我们通过使用双重指针的解引用运算符arr[i][j]来访问short**指针指向的short数组

c++ 我有一个short怎么拿到它指向的short数组

原文地址: https://www.cveoy.top/t/topic/iHHX 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录