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 1075425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:16:16+00:00 2026-05-16T21:16:16+00:00

In C++ specifically, what are the semantic differences between for example: static const int

  • 0

In C++ specifically, what are the semantic differences between for example:

static const int x = 0 ;

and

const int x = 0 ;

for both static as a linkage and a storage class specifier (i.e. inside and outside a function).

  • 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. Editorial Team
    Editorial Team
    2026-05-16T21:16:16+00:00Added an answer on May 16, 2026 at 9:16 pm

    At file scope, no difference in C++. const makes internal linkage the default, and all global variables have static lifetime. But the first variant has the same behavior in C, so that may be a good reason to use it.

    Within a function, the second version can be computed from parameters. In C or C++ it doesn’t have to be a compile-time constant like some other languages require.

    Within a class, basically the same thing as for functions. An instance const value can be computed in the ctor-initializer-list. A static const is set during startup initialization and remains unchanged for the rest of the program. (Note: the code for static members looks a little different because declaration and initialization are separated.)

    Remember, in C++, const means read-only, not constant. If you have a pointer-to-const then other parts of the program may change the value while you’re not looking. If the variable was defined with const, then no one can change it after initialization but initialization can still be arbitrarily complex.

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

Sidebar

Related Questions

Specifically, is the following legal C++? class A{}; void foo(A*); void bar(const A&); int
specifically, will working with containers as opposed to the static ObjectFactory let me keep
Specifically I am worried about this scenario : 1) I write a class with
Specifically I want to make a QR code to http://example.com be the favicon for
Specifically I want all PasswordBox's using a Style to have the same static KeyDown
Specifically, I would like to share a set of utility methods between NSTreeNode and
I'm thinking specifically about the generic class HashSet<T> . It implements several interfaces, but
I have a class that is using boost::aligned storage to statically allocate memory within
Is there a pre-existing function or class for URL normalization in PHP? Specifically, following
Specifically, I just want to generate a cryptographically secure random number between 0 and

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.