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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:50:40+00:00 2026-05-30T17:50:40+00:00

From http://sourcemaking.com/design_patterns/strategy/cpp/1 : class TestBed { public: enum StrategyType { Dummy, Left, Right, Center

  • 0

From http://sourcemaking.com/design_patterns/strategy/cpp/1:

class TestBed
{
  public:
    enum StrategyType
    {
        Dummy, Left, Right, Center
    };
    TestBed()
    {
        strategy_ = NULL;
    }
    void setStrategy(int type, int width);
    void doIt();
  private:
    Strategy *strategy_;
};

Note how the private members have been declared at the end. I have seen this programming style at several other places, but somehow I find declaring private members first easier to read.

Are there any advantages of declaring private members at the end of the class, like done above?

  • 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-30T17:50:41+00:00Added an answer on May 30, 2026 at 5:50 pm

    When reading a class declaration the most important thing is the public interface and so it makes sense to go at the top. Your eyes shouldn’t be drawn to the private members which hold the implementation.

    It really doesn’t matter much though. Pick a style (or be given one) and stick with it.

    Actually, the only thing I can really think of it changing is the order of initialization of members. That seldom matters though.

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

Sidebar

Related Questions

From http://www.learncpp.com/cpp-tutorial/125-the-virtual-table/ , code such as class Base { public: virtual void function1() {};
From http://www.learncpp.com/cpp-tutorial/97-overloading-the-increment-and-decrement-operators/ Class declaration class Digit { private: int m_nDigit; public: Digit(int nDigit=0) {
From http://www.learncpp.com/cpp-tutorial/142-function-template-instances/ class Cents { private: int m_nCents; public: Cents(int nCents) : m_nCents(nCents) {
From http://items.sjbach.com/319/configuring-vim-right (2009 archive from original) I got that you were supposed to be
From http://csharpindepth.com/Articles/Chapter8/PropertiesMatter.aspx using System; struct MutableStruct { public int Value { get; set; }
From http://www.learncpp.com/cpp-tutorial/19-header-files/ How does the linker know that it needs to include the standard
Using the function from: http://msdn.microsoft.com/en-us/library/system.security.cryptography.rijndaelmanaged.aspx public static byte[] encryptStringToBytes_AES(string plainText, byte[] Key, byte[] IV)
Using the Generator class from http://unpythonic.blogspot.com/2007/08/using-threads-in-pygtk.html , the following code makes my program fail:
From http://msdn.microsoft.com/en-us/library/aa287786(v=vs.71).aspx public string Name { get { return name; } set { name
//This program is taken from http://www.learncpp.com/cpp-tutorial/114-constructors-and-initialization-of-derived-classes/ #include <iostream> using namespace std; class A {

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.