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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:10:16+00:00 2026-05-17T02:10:16+00:00

I had a C++ interview recently where I was asked, how does the compiler

  • 0

I had a C++ interview recently where I was asked, how does the compiler differentiate static data members having the same name in two different classes?

Since all static data variables are stored in the data segment, there has to be a way by which the compiler keeps track of which static data belongs to which class especially when they have the same name.

Edit:
I answered name mangling, but he refused saying name mangling is used only among the members of the same class.

  • 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-17T02:10:17+00:00Added an answer on May 17, 2026 at 2:10 am

    The names are mangled with their class name in them. An example with the clang compiler

    class A {
      static int i;
    };
    
    int A::i = 0;
    

    Output

    $ clang++ -cc1 -emit-llvm main1.cpp -o -
    ; ModuleID = 'main1.cpp'
    target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
    target triple = "i386-pc-linux-gnu"
    
    @_ZN1A1iE = global i32 0, align 4
    

    Where _ZN1A1iE is

    $ c++filt _ZN1A1iE
    A::i
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had an interview recently and he asked me about Singleton Design Patterns about
This task has already been asked/answered, but I recently had a job interview that
I had an interview recently where I was asked to produce the traditional FizzBuzz
Recently i had an interview in which the question was asked as How would
Recently I had an interview and I was asked to write a algorithm to
I have recently had two telephone interviews where I've been asked about the differences
I was asked this question in an interview. If you had two numbers represented
I recently had an interview where I was asked to connect to the companies
Recently I had a question on the interview - I was asked to compare
Recently in an interview I was asked to write a query where I had

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.