Chapter 4. Arrays, Strings, and Pointers

So far, you 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 will learn about:

  • Arrays and how you use them

  • How to declare and initialize arrays of different types

  • How to declare and use multidimensional arrays

  • Pointers and how you use them

  • How to declare and initialize pointers of different types

  • The relationship between arrays and pointers

  • References, how they are declared, 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

  • What interior pointers are and how you can create and use them

In this chapter you'll be using objects more extensively although you have not yet explored the details of how they are created so 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 ...

Get Ivor Horton's Beginning Visual C++®2008 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.