answersLogoWhite

0

What is meant by 'static' in C plus plus?

Updated: 8/17/2019
User Avatar

Wiki User

14y ago

Best Answer

Static in C/C++ means that the variable will keep its value across calls to the function.

ex:

func() {

static int x=0;

++x;

cout << x << endl;

}

main() {

func();

func();

func();

}

This will print:

1

2

3

*NOT*

1

1

1

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is meant by 'static' in C plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is meant by println in c plus plus?

println is not a C++ keyword.


Static vs dynamic binding in c plus plus?

Static binding occurs at compile time. Dynamic binding occurs at runtime.


What is storage classes in c plus plus?

AUTO EXTERN STATIC are the storage classes in c++


Difference between procedure and function in C or C plus plus or Java language?

In C there are functions only, In Java methodsonly (static methods as well), in C++ both.


How do you write a program in c plus plus in which static variables are declared?

#include &lt;stdio.h&gt; static int myvar1, myvar2; int main (void) { puts ("It was easy"); return 0; }


Does c and c plus plus support static or dynamic binding?

Yes and no. Static vs dynamic binding is not a C or C++ language issue; it is a linker issue. If you link with a .lib file that contains stubs for run-time loading, then the called routine will not be loaded until it is invoked, and it will not be made a part of the load module.


What is default name of c plus plus?

If you mean the original name of C++, it was originally called "C with Classes". However, after the introduction of template metaprogramming, it was renamed C++ which meant "the successor to C".


What is meant by static identifier?

Nothing. I guess you mean a static variable.


What is static variable in the class for c plus plus?

Static member variables are local to the class. That is, there is only one instance of a static member variable, regardless of how many objects are instantiated from the class. As such, they must be declared inside the class, and defined outside of the class.


When do we use int in c plus plus programming?

'int' is one of the built-in data-types, it is meant to hold integer values.


Can you overload static functions in c plus plus?

Yes, but overloads cannot differ by return type alone. The signatures must differ by the number and/or the type of the arguments.


How is dynamic initialisation achieved in c plus plus?

The C++ standard has this to say about dynamic initialisation:"Objects with static storage duration shall be zero-initialised before any other initialisation takes place. Zero-initialisation and initialisation with a constant expression are collectively called static initialisation; all other initialisation is dynamic initialisation."