O'Reilly logo

SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION by Jesse Liberty

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

Relaxing “Declare Before Use” Within Classes

Members of a class are declared in the class declaration. In the implementation, the order of declarations in the class does not affect visibility, so a member function declared first in the class can call on a function declared fifth. In effect, every member in the class declaration is visible to every member function implementation.

This does not hold true within the class declaration. The following would be invalid because anOperator has not been declared before it is used for a formal argument in Accumulate():

void Accumulate
(
    anOperator theOperator,
    float theOperand = 0
);
enum anOperator
   {add,subtract,multiply,divide,query,reset} ;

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