zoukankan      html  css  js  c++  java
  • 24.结构体数组堆上分配内存初始化

     1 #include <iostream>
     2 #include <cstdlib>
     3 using namespace std;
     4 
     5 struct info
     6 {
     7     int id;
     8     int num;
     9     //堆上面开辟内存必须有构造函数
    10     info(int nid, int nnum) :id(nid), num(nnum)//构造函数
    11     {
    12 
    13     }
    14 };
    15 
    16 void main()
    17 {
    18     info *p = new info[2]{ {1,3},{2,3} };
    19     for (int i=0;i<2;i++)
    20     {
    21         cout << p[i].id << "  " << p[i].num << endl;
    22     }
    23 
    24     
    25     cin.get();
    26 }
  • 相关阅读:
    模块的初始
    requests模块的高级用法
    爬虫数据解析方式
    2th
    0
    ..
    .

    1th-绪论
    Py2x & Py3x版本的区别
  • 原文地址:https://www.cnblogs.com/xiaochi/p/8545920.html
Copyright © 2011-2022 走看看