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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:23:07+00:00 2026-05-14T08:23:07+00:00

HI, In C++ inner class, class A { public: void f1(); private: void f2();

  • 0

HI,

In C++ inner class,

class A {
    public: 
         void f1();
    private:
         void f2();
    class B {
       private void f3(); 
    };

 }

Does an inner class (B) has a pointer to its parent class (A)? (like it does in Java).
And can B calls its parent class public/private method (like it does in Java).

Thank you.

  • 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-14T08:23:07+00:00Added an answer on May 14, 2026 at 8:23 am

    No — in C++, nesting classes only affects names and visibility, not the semantics of the class itself. As far as generated code goes, the nested class is no different from one that isn’t nested.

    All that’s changed is the visibility and the name (e.g. if it’s in a private: section of the outer class, it’s not visible to the outside world, and if it’s in a public: section, it’s visible, but (of course) to name it you use outer_class::inner_class. It’s still a completely separate class though — just for example, you can create an instance of the inner class without creating any instance of the outer class.

    Edit: Sorry, I missed part of your question. In C++ 0x, the inner class does have access to the the private parts of the outer class — in essence, it’s as if the outer class has declared the inner class as its friend, so private names are visible, but you still need to pass it something like a reference to an object of the outer class before it can invoke any non-static member functions of the outer class.

    Although this isn’t supposed to be the case yet, I believe most compilers implement this particular part already.

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

Sidebar

Related Questions

If I have an inner class, like this: public class Test { public class
(Java question) If I reference a field in an inner class, does this cause
I have a java class: it.eng.ancona.view.RuoliView$TabElaborazioneFattureValidazione$ElencoDettaglioElaborazioneFattureValidazione$RigaElencoDettaglioElaborazioneFattureValidazione It's so long for multiple inner class. If
How can i make the inner table to overlap the parent div with 5
What is the main difference between an inner class and a static nested class
I often refactor code first by creating an inner class inside the class I'm
I have a query that has 7 inner joins (because a lot of the
public class MainFrame extends JFrame { MainFrame() { JButton zeroButton = new JButton(0); add(zeroButton);
The code has a JPanel with an inner JPanel that displays awt drawing. Upon
I'm writing an inner loop that needs to place struct s in contiguous storage.

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.