Static member functions are scoped to the class and it can be called only by using an object of the class.
No, these have their special uses, but are not common constructs. Many complex and powerful programs have neither. There might, however, be times when these offer the only solution.
Static data is scoped to the class. In this manner, static data is available only through an object of the class, through an explicit call using the class name if they 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.
Yes because they are member variables and their access can be controlled like any other. If they are private, they can be accessed only by using member functions or, more commonly, static member functions.
Because objects are more flexible and powerful than error codes. They can convey more information, and the constructor/destructor mechanisms can be used for the creation and removal of resources that might be required to properly handle the exceptional condition.
Here the Templates are built in to the C++ language and are type-safe.But Macros are implemented by the preprocessor and are not type-safe
The parameter to the template creates an instance of the template for each type. If we create six template instances, six different classes or functions are created. The parameters to the function change the behavior or data of the function, but only one function is created.
The constructor will be called to initialize a class. This special function has the same name as the class.
Making member data private enables the client of the class to use the data without being dependent on how it is stored or computed. For example, if the Cat class has a method GetAge(), clients of the Catclass can ask for the Cat's age without knowing or caring if the Catstores its age in a member variable or computes its age on-the-fly. This means the programmer of the Catclass can change the design of the Catclass in the future without requiring all of the users of Catto change their programs as well.
Here the cerr is not buffered. Everything written to cerris immediately written out. This is fine for errors to be written to the console screen, but might have too high a performance cost for writing logs to disk. But clog buffers its output, and thus can be more efficient, at the risk of losing part of the log if the program crashes.