- Home
- Course Category
- Course Result
- Course Detail
Hot Line: 0124-2383121
Course Introduction
Static Keyword
Static keyword has different meanings when used with different types. We can use static keyword with:
Static Variables : Variables in a function, Variables in a class
Static Members of Class : Class objects and Functions in a class
Source Code:Static Keyword
/* C++ Program - to illustrate class objects as static */ #includeusing namespace std; class GfG { int i = 0; public: GfG() { i = 0; cout << "Inside Constructor\n"; } ~GfG() { cout << "Inside Destructor\n"; } }; int main() { int x = 0; if (x==0) { static GfG obj; } cout << "End of main\n"; }
When the above code is compiled and executed, it produces the following result −
Width of box : 10