Exploring Important C++ Features
摘要
This chapter begins by exploring C++ special features such as friend member functions and friend classes for accessing objects’ private data and member functions. Then, hands-on activities use friend member functions and friend classes to access the object’s secret data. Later, you look at some ways to pass arguments to functions to communicate with objects efficiently. As part of practice, you do activities related to passing arguments by copying values, passing pointers, and references. These activities help you choose the right way to pass arguments to functions. Next, you see how to handle the sharing of data among objects of a class using static fields (data members) and static member functions. It helps you to handle allocating and accessing common data of objects. You practice static fields and static member functions for handling situations such as controlling all object’s activities and accessing their common data. Finally, you will learn importance of a variety of const pointers and learn how to restrict accidental changes to data members of objects.