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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:38:27+00:00 2026-06-14T18:38:27+00:00

Plain constant variables in C++ default to internal linkage. Suppose If I have the

  • 0

Plain constant variables in C++ default to internal linkage.
Suppose If I have the following:

  • I define a const variable in a header file(const int var = 2)

  • Then I include the header in two cpp files.

If I try getting the address of that const variable (i.e &var) in both of the cpp files, then will those two addresses be same? Also I need a small working code to verify this fact.

I had to post this as a question because I couldn’t ask it there in the comments for this answer given in this thread as I’m a newbie.

  • 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-06-14T18:38:28+00:00Added an answer on June 14, 2026 at 6:38 pm

    For C++ it won’t be the same due to the internal linkage – these are 2 distinct objects.
    In C it’s the other way around and const will have external linkage, thus you will get a linkage error due to redefinition.

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

Sidebar

Related Questions

Is there any way to have multi-line plain-text, constant literals in C++, à la
Is there a way to dynamically create constant variables on the fly? The idea
I have a file called myConstants.h that I use to put all the constants
A PHP constant is defined like this: define('const_name','const_value'); Tried like this: define('const_name', $variable_name); Why?
I have a constant value that I only plan to use once in my
I have programming experience with higher-level languages, and have started coding in plain C
I want to write something like Skype, i.e. I have a constant audio stream
I've been using the [constant] pragma, and have a quick question on how I
What's the difference between a String Constant and String Literal in plain C? This
Is it possible to have one enumeration constant extend another one (from the same

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.