answersLogoWhite

0

Static data members are different from automatic ones in the way that their lifetime is equals to the lifetime of your program. Even if you have declared static members inside of function (class) other than main();

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

What is static class?

A static class is a class where all the members are declared static.


Are the methods or members of static class static?

A static class may or may not have static members. Adding the static keyword to the class definition won't change this. Note that an inner class which is not static may not contain static members (unless those members are also declared final).


How you declare class scoped variables and member functions?

To scope class members to the class (rather than to instances of the class), declare them as static members of the class. Static members are accessible even when no instances of the class exist. As such, static member functions do not have access to a 'this' pointer, unlike ordinary (nonstatic) member functions.


Difference between static and non static constructor?

A static constructor is used to do anything you need done before any static methods are called such as static variable initialization. In Java (as in C#) when a static constructor is called is non-deterministic but will always be called before a static method on the same class.


What was the main difference between members of the middle class and members of the lower class?

Access to education, often laws were overlooked by the bourgoisie


What do you understand by static members?

Static members are local to the class in which they are declared. Unlike instance members (non-static members), they are not associated with any one instance of the class, and are available (access permitting) even when no instance of the class exists. They can be thought of as being global functions and variables, but with a much more refined scope.


What is a static data linkage?

Static data members of a class in namespace scope have external linkage. Static data members follow the usual class access rules, except that they can be initialized in file scope. Static data members and their initializers can access other static private and protected members of their class. The initializer for a static data member is in the scope of the class declaring the member. A static data member can be of any type except for void or void qualified with const or volatile. The declaration of a static data member in the member list of a class is not a definition. The definition of a static data member is equivalent to an external variable definition. You must define the static member outside of the class declaration in namespace scope.


Why is it not advisable to use this pointer with static members?

It is not inadvisable, it is impossible. Static member methods do not have access to a this pointer since they are not associated with any instance. Static members are scoped to the class, not to an object (an instance of the class). Only instance members have access to the this pointer.


When do you declare a member as static in java?

You declare a member static whenever the member should be regarded as being local to the class rather than being local to objects of the class. Static members are shared by all instances of the class. Static methods of a class differ from ordinary members in that they do not have an implicit "this" reference, which means they can be invoked even when no instances of the class exist.


What kinds of members can a class have?

Members of a class may include 1. Static Methods 2. non-static methods 3. Instance variables 4. Sub classes etc.


Can Static data members be declared either in the private or public section of class declaration?

Yes. Static members can be private or public. (Or protected.)


What is the difference between static data member and ordinary data member?

Static data is data that does not change from program load to program exit. Static data member do not apply for c. In c++, a static data member is one that is common for all instances of that class.