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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:36:47+00:00 2026-05-21T16:36:47+00:00

I am asking this question for the discussion. Suppose i have flowing class hierarchy

  • 0

I am asking this question for the discussion.

Suppose i have flowing class hierarchy

    class  A
    {
    public:
         static int varr;
    }

    class B : public A
    {

    }

    Class C : public A
    {
    }

If I create the Object of B b1,b2,b3; and C c1,c2,c3; and A a1, a2;

1.will varr is shared across all the object mentioned above or there will be separate instance for different object?

2.if b1 object change the value it will be reflected for c1 object or not.

  • 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-21T16:36:48+00:00Added an answer on May 21, 2026 at 4:36 pm

    Yes, it will be shared accross all the instance of all derived(B,C) and base class(A)..

    Only one instance for a static object will be created, and at all place that object will be refered. So if you change at one place it means change will be reflected at all location where its being refered.

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

Sidebar

Related Questions

I am finally asking this question as I have never actually found an answer.
I'm asking this question because I have gone through the tutorial posted here: Preventing
The discussion in this question is the direct cause for me asking this question.
Before asking this question I have Googled for this problem and I have looked
For the purpose of asking this question about ordering. The following MyObject class returns
Asking this question here because in CakePHP google group got no answer.I have the
In asking this question, I'm looking for either better understanding of the situation or
I searched before asking this question. I didn't find an answer probably because I
I am asking this question here because it is my understanding that this is
I searched SO before asking this question, I am completely new to this 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.