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

The Archive Base Latest Questions

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

I know Thinking in C++ by Bruce Eckel is not a reference book but

  • 0

I know Thinking in C++ by Bruce Eckel is not a reference book but I found a strange paragraph and I don’t understand if it’s still applicable today:

Making a structure nested doesn’t automatically give it access to
private members. To accomplish this, you must follow a particular
form: first, declare (without defining) the nested structure, then
declare it as a friend, and finally define the structure. The
structure definition must be separate from the friend declaration,
otherwise it would be seen by the compiler as a non-member.

I actually tried this without declaring the nested structure as a friend and it worked:

struct myStruct{
private:
    int bar;
public:
    struct nestedStruct{
        void foo(myStruct *);
    }a;
};

void myStruct::nestedStruct::foo(myStruct * p){
    p->bar = 20;
}

Is there still a need to declare a nested structure friend in order to modify the private members of the base 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-06-12T18:25:28+00:00Added an answer on June 12, 2026 at 6:25 pm

    That quote is wrong. A nested inner class-type has access to all members (including private) of the enclosing class-type.

    This was not the case in C++98, and your edition probably refers to that version of the standard. In C++03 and C++11 the quote doesn’t apply.

    11.7 Nested classes [class.access.nest]

    1 A nested class is a member and as such has the same access rights as any other member. The members of
    an enclosing class have no special access to members of a nested class; the usual access rules (Clause 11)
    shall be obeyed.

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

Sidebar

Related Questions

Don't know if I'm over-thinking this or not.. but I'm trying to be able
I (think I) know what you're thinking... not another EXC_BAD_ACCESS question but I'm really
I don't know if I'm thinking the right way or not. In my rails
I know I'm over looking this or over thinking this but I can not
I know what you're thinking - oh my god, seriously, not again - but
I'm reading through a book on C++ standards: Thinking in C++ by Bruce Eckel.
I don't know if I am thinking in the wrong way about TPL, but
I was thinking along the lines of using typeid() but I don't know how
I'm thinking in learning Zend or Symfony frameworks but I don`t know which one
I don't know if I'm thinking of this the right way, and perhaps somebody

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.