O'Reilly logo

Ivor Horton's Beginning Visual C++ 2013 by Ivor Horton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5Introducing Structure into Your Programs

  • How to declare and write your own C++ functions
  • How function arguments are defined and used
  • How to pass arrays to and from a function
  • What pass-by-value means
  • How to pass pointers to functions
  • How to use references as function arguments, and what pass-by-reference means
  • How the const modifier affects function arguments
  • How to return values from a function
  • How to use recursion

You can find the wrox.com code downloads for this chapter on the Download Code tab at www.wrox.com/go/beginningvisualc. The code is in the Chapter 5 download and individually named according to the names throughout the chapter.

UNDERSTANDING FUNCTIONS

Up to now, you haven’t really been able to structure your program code in a modular fashion, because you only know how to construct a program as a single function, main(); but you have been using library functions of various kinds as well as functions belonging to objects. Whenever you write a C++ program, you should have a modular structure in mind from the outset, and as you’ll see, a good understanding of how to implement functions is essential to object-oriented programming.

There’s quite a lot to structuring your C++ programs, so to avoid indigestion, you won’t try to swallow the whole thing in one gulp. After you have chewed over and gotten the full flavor of these morsels, you move on to the next chapter, where you get ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required