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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:37:04+00:00 2026-06-01T00:37:04+00:00

I’m trying to use an open-source project. Both the latest official (from a *.tar.gz

  • 0

I’m trying to use an open-source project. Both the latest official (from a *.tar.gz file) and the bleeding-edge (from a SVN repository) versions do stuff like:

class Type1 {
    friend class Ridiculous;
    friend class Number;
    friend class Of_Friends;

    int  ImportantPrivateSemiSharedData;
};

 // In another header...

class Ridiculous {
    class Inner {
        void  MyFunc( Type1 &t )
        { /*do something with t.ImportantPrivateSemiSharedData*/ }
    };
};

AFAIK, marking class A as a friend of class B does not give any type associated with A friendship rights with B. Neither classes derived from A nor classes that are friendly with A get friendship with B. I would think that limitation also applies to inner classes.

I’m using a computer from 2002 stuck several operating-system versions back, while the program (and presumably its design team) is mainly on newer computers. Is my system compiler just old and busted, or are the new-hotness’s compilers allowing something they shouldn’t? Is this a C++11 change?

I just want to use this program, but I keep getting stuck on things like this. I’m already suspicious because the code is full of techniques like “private data with a ridiculous number of friends” and “inner classes everywhere,” which I think are code smells. The team is using these techniques together, but I think that they’re fundamentally incompatible since friendship doesn’t carry over and you can’t forward-declare inner classes.

(If it’s needed, I’m using Mac OS X Tiger 10.4.11/PowerPC 32-bit (a G4-equipped eMac). The program is LLVM and CLang (and LLVM Test Suite), trying from both the v3.0 archives and r153311 from Subversion. The compiler is the Apple-supplied GCC 4.0.1 with XCode 2.5.)

Addendum

Seeing the first responses, now I suspect that marking a class as a friend has two interpretations. Given a class A that has a friend class X in it, that declaration can grant access to:

  1. a member function (static or special or neither) of X.
  2. any function, including special ones, whose fully-qualified name has the
    fully-qualified name of X as a prefix.

I think my compiler uses the first definition, while the writers’ compiler uses the second. Has there been official word to which interpretation is correct? If so, when did the specification happen (C++98/03, a defect report, C++11)? I’ve always thought friendship meant the first version (including C++ material I’ve read); the second never entered my mind until now.

  • 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-01T00:37:06+00:00Added an answer on June 1, 2026 at 12:37 am

    I think there are two issues at play here. One is that the code smells bad, as you say, and the second is that it doesn’t compile on your system. Regarding the smell, yes, excessive use of the friend keyword often indicates bad OO design. It is generally better to give an object what it needs to do its job rather than pull something out of it, which is essentially what friend lets you do.

    Large numbers of inner classes, IMO, are not that bad, as they merely serve to keep classes within the scope of another. This helps keep the namespace less cluttered and allows you to use common names across different functional areas.

    Regarding the compilation issue, I tried to reproduce this on my system (Ubuntu 10.04, gcc 4.4.3, two years old at this point), and created this sample program:

    class A
    {
        friend class B;
    
        int x;
    };
    
    class B
    {
        class Inner
        {
        public:
            void foo(A& a)
            {
                a.x++;
            }
        };
    
    public:
        void bbb()
        {
            Inner i;
            A a;
    
            i.foo(a);
        }
    };
    
    int main()
    {
        B b;
    
        b.bbb();
    }
    

    This compiled with no errors or warnings. I initially had nothing marked public, but I needed to add bbb() to create an instance of class Inner, and I had to add a public method of Inner so I could invoke it to do something with an A.

    The upshot is that I think your development system is out of date. The main developers clearly have no problem compiling their code, so the difference has to be with your system, or else they have configured their systems in a way that they are not telling you about. That being said, I think they could do more to make their code more portable and easier to build. In an open source project, that is to be expected if you want others to contribute.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.