Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 141591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:48:04+00:00 2026-05-11T07:48:04+00:00

I’ve heard there are differences between languages about the meaning of the keyword static

  • 0

I’ve heard there are differences between languages about the meaning of the keyword static, but I’ve not found a good list that consolidates those differences.

Here’s what I know about the meaning of static in C++:

  • For local static variables within a function, the variable is initialized at startup and the value is saved across function calls.
  • Static data members are shared among all instances of a class. In other words, there is only one instance of a static data member. Static data members must be initialized at file scope.
  • Static member functions have access only to static members.
  • In recursive code, a static object or variable is guaranteed to have the same state in different instances of a block of code.
  • Static objects and variables defined at file scope only have internal linkage. No other files may use them.

How does the meaning of static change in other languages?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T07:48:05+00:00Added an answer on May 11, 2026 at 7:48 am

    C


    • The keyword can change either the linkage or the duration (lifetime) of an object.
    • Variables are always initialized to 0
    • Functions have internal linkage.
    • If declared in file level scope: variables have internal linkage and static duration (i.e. exists throughout the lifetime of the program)
    • If declared in block scope: variables have no linkage but static duration
    • There can multiple declarations of the same static variable in a translation unit. However, note that they must be the same. E.g: at file-level scope:

    int a;        // a has external linkage  static int a; // a now has static linkage               // same as if you wrote: static int a = 0;  //...  static int b; // static linkage  extern int b; // extern loses its meaning, b still has internal linkage  //...  extern int b; // b has external linkage  static int b; // error  //...  void func() {   static int x; // automatic linkage, static duration                 // same as if you wrote: static int x = 0; } 

    C++


    • At file level scope the usage has been deprecated for both variables and members in favor of anonymous namespaces. Exists only as compatibility
    • Variables still get default initialized (as in C) to 0
    • ‘6.7 The zero-initialization (8.5) of all local objects with static storage duration (3.7.1) or thread storage duration (3.7.2) is performed before any other initialization takes place […] ‘
    • Variables have static storage duration unless accompanied by a thread_local specifier (from C++0x onwards)
    • There can be only one definition of a static in a translation unit
    • Member variables/functions mean they are properties of the class and not the instances Legal access syntax: instance.property or Class::property
    • Static member functions can only access only static member variables No this pointer for such functions
    • Non-static members can however access any static member
    • At file level objects have internal linkage except for class members which have a class scope
    • Class members need to be defined either in the class declaration or outside explicitly via class name and scope resolution operator
    • Cannot use this in a static method

    ActionScript


    • Class methods as in C++
    • cannot use this or super in a static method
    • Accessed only through class name and not instance name
    • Not inherited
    • Derived classes however have access to bases’ static properties
    • Variables that are declared with both the static and const keywords must be initialized at the same time as you declare the constant

    Object Oriented Design


    • The Singleton design pattern is considered by many as a glorified static object
    • Used in Factory design pattern

    I may have missed a lot of other things — feel free to chip in.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
Seemingly simple, but I cannot find anything relevant on the web. What is the
I need a function that will clean a strings' special characters. I do NOT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.