zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    python模块搜索路径
    Python数据结构
    Python文件类型
    Python循环语句
    Python条件语句
    python配置文件操作——configparser模块
    python 加密方式(MD5&sha&hashlib)
    python MySQL 获取全部数据库(DATABASE)名、表(TABLE)名
    python sqlite3查看数据库所有表(table)
    027.MFC_映射消息
  • 原文地址:https://www.cnblogs.com/MCSFX/p/15320906.html
Copyright © 2011-2022 走看看