O'Reilly logo

Sams Teach Yourself C++ in 24 Hours, Third 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

Q&A

Q1:Why use static data when you can use global data?
A1: Static data is scoped to the class. It therefore is available only through an object of the class—through an explicit and full call using the class name if the data are public, or by using a static member function. Static data is typed to the class type, however, and the restricted access and strong typing makes static data safer than global data.
Q2:Why use static member functions when you can use global functions?
A2: Static member functions are scoped to the class, and can be called only by using an object of the class or an explicit full specification (such as ClassName::FunctionName()).
Q3:Why not make all classes friends of all the classes they use?
A3: Making one class a friend ...

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