what is static data member and static member function? how can we overload a function?
A static data member in C++ is a class variable that is shared among all objects of a class and is defined using the 'static' keyword. It has a single instance for the entire class, and its value is shared by all objects of that class. Unlike non-static class members, a static data member can be accessed without creating an instance of the class.
A static member function in C++ is a member function of a class that can be called without creating an instance of the class. Like static data members, a static member function operates on the class as a whole rather than on individual objects. A static member function can only access static data members on other static member functions of the same class.
To overload a function in C++, you create multiple functions with the same name but different parameter lists. The correct function to call is determined at compile-time based on the number and types of arguments passed to the function.
No comments:
Post a Comment
If you have any doubts, please let me know