How to Declare a Static Member Function in a Class in C++? Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report In C++, static functions are functions that are directly associated with a class so we can access the static function directly without creating an object of the class using the scope resolution operator. In this article, we will learn how we can declare a static function in a class in C++. Declare a Static Function in a Class in C++To declare a static member function, we can simply use the static keyword during the declaration of the function inside the class. Then we can use the scope resolution (::) operator to call the static function using the following syntax. Syntax to Declare a Static Member FunctionClassName:: static_Function().C++ Program to Declare a Static Function in a Class C++ // C++ program to declare a static function in a class #include <iostream> using namespace std; class Student { private: int marks; int id; string Name; public: // Declare a static function in the class static void staticFunc() { cout<<" Static function executed successfully"<<endl; } }; //Driver Code int main() { // Call the static function using scope resolution operator Student::staticFunc(); return 0; } Output Static function executed successfully Comment More info G gaurav472 Follow Improve Article Tags : C++ Programs C++ cpp-class C++-Class and Object C++-Static Keyword CPP-OOPs CPP Examples +3 More Explore C++ BasicsIntroduction to C++3 min readData Types in C++7 min readVariables in C++4 min readOperators in C++9 min readBasic Input / Output in C++5 min readControl flow statements in Programming15+ min readLoops in C++7 min readFunctions in C++8 min readArrays in C++8 min readCore ConceptsPointers and References in C++5 min readnew and delete Operators in C++ For Dynamic Memory5 min readTemplates in C++8 min readStructures, Unions and Enumerations in C++3 min readException Handling in C++11 min readFile Handling through C++ Classes8 min readMultithreading in C++8 min readNamespace in C++5 min readOOP in C++Object Oriented Programming in C++8 min readInheritance in C++10 min readPolymorphism in C++5 min readEncapsulation in C++4 min readAbstraction in C++4 min readStandard Template Library(STL)Standard Template Library (STL) in C++3 min readContainers in C++ STL3 min readIterators in C++ STL10 min readC++ STL Algorithm Library2 min readPractice & ProblemsC++ Interview Questions and Answers1 min readC++ Programming Examples4 min read Like