• VS调试时查看动态数组的全部元素


    转载:https://blog.csdn.net/sinat_36219858/article/details/80720527

    #include <iostream>
    using namespace std;
    class Mat
    {
    public:
    int *p=NULL;
    Mat(int size)
    {
    if (size>0)
    p = new int[size];
    }
    ~Mat()
    {
    if (p != NULL)
    delete[]p;
    p = NULL;
    }
    };

    int main()
    {

    int *a= new int[4];
    a[0] = 1;
    a[1] = 2;
    a[2] = 3;
    a[3] = 4;

    int **b = new int*[2];
    b[0] = new int[2];
    b[1] = new int[2];
    b[0][0] = 1;
    b[1][0] = 2;
    b[0][1] = 3;
    b[1][1] = 4;

    Mat mat(4);
    mat.p[0] = 1;
    mat.p[1] = 2;
    mat.p[2] = 3;
    mat.p[3] = 4;

    int d[] = { 1, 2, 3, 4, 5 };

    }

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    用VS的快速监视查看数组内容。
    进入调试状态后,工具栏调试中找到快速监视。
    对于一维数组a[4], 数组名+逗号+长度


    对于二维数组b[2][2],要按行查看内容,第一行就用b[0],2


    查看类的成员变量数组,加上对象访问到成员后和普通数组一样。mat.p,4

    对于栈上的数组d[5],只要数组名就会显示所有内容

    ————————————————
    版权声明:本文为CSDN博主「ims-」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/sinat_36219858/article/details/80720527

  • 相关阅读:
    c字符指针与字符数组的区别
    BiLstm原理
    TensorFlow中assign函数
    TensorFlow Training 优化函数
    TensorFlow 神经网络相关函数
    TensorFlow 算术运算符
    TensorFlow函数:tf.reduce_sum
    TensorFlow函数教程:tf.nn.dropout
    TensorFlow占位符操作:tf.placeholder_with_default
    TensorFlow函数:tf.random_shuffle
  • 原文地址:https://www.cnblogs.com/MCSFX/p/15320906.html
Copyright © 2020-2023  润新知