课程: Complete Guide to C++ Programming Foundations
免费学习该课程!
今天就开通帐号,24,100 门业界名师课程任您挑!
Arrays
- [Eduardo] Arrays are collections of data. Each element is accessible by an index. Elements are homogeneous, meaning that they are all of the same data type. Arrays are fixed in size, so you may not resize them. And lastly, elements are continuous in memory. That means that the whole array is a sequential block of memory addresses. So, let me show you some arrays. Let's start at line eight with an array of integers where we want to store the number of enemies per level in a run-and-gun video game. The syntax goes like this. First we specify the type, that's int, then comes the name of the array, enemies, and then between square brackets the capacity of the array. We'll use 4. Now let me assign values to each element in the array. Now, this is important. Arrays in C and C++ are indexed from zero to N minus one, where N is the capacity of the array. This is a common source of bugs for beginners, so please try to keep it in mind. To access an element for reading or writing you simply…
内容
-
-
-
-
-
-
(已锁定)
Arrays7 分钟 27 秒
-
Pointers7 分钟 59 秒
-
(已锁定)
How arrays and pointers are related5 分钟 14 秒
-
(已锁定)
Using objects with pointers10 分钟 56 秒
-
(已锁定)
The vector class5 分钟
-
(已锁定)
Using objects with vectors6 分钟 29 秒
-
(已锁定)
References4 分钟 56 秒
-
(已锁定)
C strings11 分钟 16 秒
-
(已锁定)
The string class4 分钟 14 秒
-
(已锁定)
Solution: Vector manipulation2 分钟
-
(已锁定)
-
-
-
-
-
-