---
title: "Discussion on \"C++数组和向量：\" | Hashnode"
description: "Discussion on \"C++数组和向量：\". 数组 (Array)\n数组是固定大小的连续内存块，在编译时确定大小。它们在内存中是静态分配的，意味着大小不可改变。\n声明和初始化数组\nint arr[5] = {1, 2, 3, 4, 5}; //声明并初始化一个包含5个整数数组\n\n优点：\n\n性能高：数组的访问速度较快，因为它们在内存中是连续的。\n\n内存占用少：没有额外的开销\n\n\n缺点：\n\n大小固定: 一旦声明，数组的大小不可更改。\n\n不便于扩展：如果需要增加元素，必须手动创建一个新的更大的数组并复制原数组的内容。\n\n\nstd::array (..."
url: "https://hashnode.com/posts/c/67c85f65c967093aa08bc8cf"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [C++数组和向量：](https://cpp-blog.hashnode.dev/c?utm_source=hashnode&utm_medium=feed)

数组 (Array) 数组是固定大小的连续内存块，在编译时确定大小。它们在内存中是静态分配的，意味着大小不可改变。 声明和初始化数组 int arr\[5\] = {1, 2, 3, 4, 5}; //声明并初始化一个包含5个整数数组 优点： 性能高：数组的访问速度较快，因为它们在内存中是连续的。 内存占用少：没有额外的开销 缺点： 大小固定: 一旦声明，数组的大小不可更改。 不便于扩展：如果需要增加元素，必须手动创建一个新的更大的数组并复制原数组的内容。 std::array (...

Mar 5, 2025 · 1 min read · cpp-blog.hashnode.dev  
Read the article

-   [#cpp](https://hashnode.com/tag/cpp)
-   [#array](https://hashnode.com/tag/array)
-   [#vector](https://hashnode.com/tag/vector)

## Written by

[Youwei Chen](https://hashnode.com/@Yuk1Juda1)

@Yuk1Juda1

  
[View profile](https://hashnode.com/@Yuk1Juda1)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
