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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:20:53+00:00 2026-06-11T12:20:53+00:00

I read a lot on static keyword, I only found static variable, static function,

  • 0

I read a lot on static keyword, I only found static variable, static function, but there is no discussion of static class, can you please explain me about this.

  • Why we use static class in c++?
  • Why we introduce this type of class?
  • Give the physical significance of static class?
  • Give the real life example of static class?
  • If there is any limitation, then tell me what?

I am waiting for your reply. Thanks in advance.

  • 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-11T12:20:55+00:00Added an answer on June 11, 2026 at 12:20 pm

    There are no static classes in C++. static refers to a storage class, i.e. it applies to objects or functions, not to data types.

    In Java, static class, when applied to classes that are nested in other classes, means that the nested class can be instantiated independently of any instance of the enclosing class. In C++ that is always the case. Nested classes in C++ are always independent data types.

    Here is what I mean: First let’s take a look at this Java code:

    public class A {
      public class B {
      }
    
      public static void main(String[] args)
      {
        A.B b1 = new A.B();  // <-- This is ill-formed, because A.B is not
                             //     an independent data type
    
        A a = new A();
        A.B b2 = a.new B();  // <-- This is correct. Use an instance of A to
                             //     create an object of type A.B.
      }
    }
    

    It defines a class A, and a nested class (i.e. a member class, or sub-class) A.B. The second line of the main program shows how you cannot instantiate a object of type A.B. You cannot do this because B is a member class of A and therefore requires an existing object of type A to be instantiated. The third line of the main program shows how this is done.

    In order to be able to instantiate an object of type A.B directly (independently of any instance of type A) you must make B a static member class of A:

    public class A {
      public static class B {   // <---- I inserted 'static'
      }
    
      public static void main(String[] args)
      {
        A.B b1 = new A.B();  // <-- This is now well-formed
    
        A a = new A();
        A.B b2 = a.new B();  // <-- This is now ill-formed.
      }
    }
    

    On the other hand, in C++ this is not required, because in C++ a member class is always an independent data type (in the sense that no instance of the enclosing class is required to be able to create instances of the nested class):

    class A
    {
    public:
      class B
      {
      };
    };
    
    int main()
    {
      A::B b;   // <--- Perfectly well-formed instantiation of A::B
      return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found a lot of question about this problem, but i can't fix it.
I read lot's of docs, tried everything and still can't understand why my template
I read a lot of different opinions on it, but is WinRT an actual
I read a lot, also here, but couldn't find a simple way to do
I read a lot of post, and i dont see my mystake. Can some
I read through a lot of circular dependency topics but all of them seem
I used a lot annotations in java but I never wrote one. I read
First of all, the static keyword. I've read several articles and past threads on
I have a lot of requests that read my Web Config file variable =
I have read a lot of stackoverflow questions but none seems to be working

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.