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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:21:40+00:00 2026-05-22T22:21:40+00:00

In the following code I have placed anonymous structures inside of my class declaration

  • 0

In the following code I have placed anonymous structures inside of my class declaration to hopefully improve the readability of it.

class example {
    private:
        struct barrier {
            boost::barrier playlist_avaliable;
            boost::barrier display_sync;
            barrier( ) : playlist_avaliable( 2 ), display_sync( 3 ) { }
        } barrier;
    public:
        example( ) { }

        void playlist_avaliable( ) {
            barrier.playlist_avaliable.wait();
        }
};

Is this any better than the alternative of having variables with names like ‘barrier_playlist_avaliable’?

  • 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-22T22:21:41+00:00Added an answer on May 22, 2026 at 10:21 pm

    Ok, some random thoughts:

    1. Leave out the ‘barrier’ after
      struct. It is redundant.
    2. It’s
      barely more than syntactic sugar. It
      is a nice way to group variables.
    3. Whether you should use the struct may be
      influenced by the question how much
      transparent the inner struct should
      be to the class example. For example, do you want the members of the struct to initialized in the constructor of example?
    4. A similar question goes for the destructor.
    5. It is more writing. This is bad.
    6. It helps wrapping a lot of annoying stuff into a single object. Interesting for copying these members or for wrapping a set of rapidly rewritten internals into a single name. This might help.
    7. you should keep it consistent throughout your code, in whatever way you define consistent.
    8. Opposite of (1): Keep the inner struct namend, but change the name slightly. Maybe it is not too far to a situation where you want to use this struct in a more extensive way.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have the following code: class some_class{}; some_class some_function() { return some_class(); }
In C++, I have a class which contains an anonymous bitfield struct. I want
Following code is an example of text placed into a textarea from a database.
I have code similar to the following in many places: var dbParams = db.ReadParams(memberID,
I'm using the following code to have a non-JS navigation: <ol id=navigation> <li id=home><a
I have three images and using the following code I have then fade in
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following Code Block Which I tried to optimize in the Optimized section
I'm trying to use opengl in C#. I have following code which fails with
currently I have the following code: String select = qry.substring(select .length(),qry2.indexOf( from )); String[]

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.