Chapter 4. Arrays, Strings, and Pointers

WHAT YOU WILL LEARN IN THIS CHAPTER:

  • How to use arrays

  • How to declare and initialize arrays of different types

  • How to declare and use multidimensional arrays

  • How to use pointers

  • How to declare and initialize pointers of different types

  • The relationship between arrays and pointers

  • How to declare references and some initial ideas on their uses

  • How to allocate memory for variables dynamically in a native C++ program

  • How dynamic memory allocation works in a Common Language Runtime (CLR) program

  • Tracking handles and tracking references and why you need them in a CLR program

  • How to work with strings and arrays in C++/CLI programs

  • How to create and use interior pointers

So far, we have covered all the fundamental data types of consequence, and you have a basic knowledge of how to perform calculations and make decisions in a program. This chapter is about broadening the application of the basic programming techniques that you have learned so far, from using single items of data to working with whole collections of data items.

In this chapter, you'll be using objects more extensively. Although you have not yet explored the details of how they are created, don't worry if everything is not completely clear. You'll learn about classes and objects in detail starting in Chapter 7.

HANDLING MULTIPLE DATA VALUES OF THE SAME TYPE

You already know how to declare and initialize variables of various types that each holds a single item of information; I'll refer to single items ...

Get Ivor Horton's Beginning Visual C++® 2010 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.