adspace
Answer Posted / Dwijendra Kumar Upadhyay
A static member function in C++ is a non-static member function that can only access other static members of its class and has no this pointer. It belongs to the class, not the object. Static functions are used when we want to share data among all objects of the same class rather than each object having its own copy.nnExample:n```cppnclass Counter {nprivate:n static int count;npublic:n Counter() { count++; }nstatic void displayCount() { cout << "Total objects: " << count << endl; }n};nint Counter::count = 0;nint main() {n Counter c1, c2, c3;n Counter::displayCount();n return 0;n}n```
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers