C++编程思想 第1卷 第3章 创建复合类型 数组 任何类型的数组

可以生成任何类型的数组


//: C03:StructArray.cpp
// From Thinking in C++, 2nd Edition
// Available at http://www.BruceEckel.com
// (c) Bruce Eckel 2000
// Copyright notice in Copyright.txt
// An array of struct

typedef struct {
  int i, j, k;
} ThreeDpoint;

int main() {
  ThreeDpoint p[10];
  for(int i = 0; i < 10; i++) {
    p[i].i = i + 1;
    p[i].j = i + 2;
    p[i].k = i + 3;
  }
} ///:~

数组是struct类型的
struct的i 和for 的 i 无关


无输出


猜你喜欢

转载自blog.csdn.net/eyetired/article/details/80720201
今日推荐