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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:50:06+00:00 2026-05-13T20:50:06+00:00

I have been coding regurlarly in C++ in the past months. I am getting

  • 0

I have been coding regurlarly in C++ in the past months. I am getting used to it step by step… but there are things that confuse me about formatting.

I know there is a lot of legacy from C that I supousee mixes with C++. This time I have doubts about how to order properly my members and functions within in a class. Also considering their access modifiers.

How is the convention in this? Until know I am doing everything “public” and writing first constructor of class, then destructor, next members and finally functions. It this correct? What happens when introducing “private” and “protected” access modifiers or “virtual” functions?

From the documents I have look in the Internet there is different ways of doing things. But my questions aims to get the knowledge from a community that develops in C++ that I want to blend into. 😉

Thanks a lot!!!

  • 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-13T20:50:07+00:00Added an answer on May 13, 2026 at 8:50 pm

    My humble opinion, after having read many style guides all over the ‘net:

    • Public first, because that is the interface of your class, which people want to see first.
    • From the same reasoning, private goes last.
    • If you have any private functions, place them before private members. (Again, same reasoning. Your members are of the least interest to anyone.)
    • Constructor first in the public section, because people have to call that before they have an object on which to invoke any functions.
    • Destructor right after the constructor, just to have them in one place.
    • Within the public / protected / private sections, find some grouping logical to any users of the library, and write a one-line comment in front of each group. (Doesn’t matter that much what’s the logic, as long as it’s documented.)
    • Don’t make any rules more complicated than this, because the more complicated, the easier to get it wrong (or just ignore it as inconvenient).

    Remember that members should be initialized in the order they are declared, and destroyed in the reverse order.

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

Sidebar

Related Questions

I have been coding since a long time but I have never ever used
I have been coding Java for a while, but I have to admit that
There have been plenty of articles about how to use reflection and LINQ to
The following have been proposed for an upcoming C++ project. C++ Coding Standards, by
Recently I've been doing lots of weekend coding, and have began to really need
Have been looking at the MVC storefront and see that IQueryable is returned from
Have been studying the file system related classes of Adobe AIR 1.5, but so
I have been working on a web services related project for about the last
I have been coding using Visual Studio 2005, in VB.NET for a while. No
I have been coding my PHP applications in Notepad. I want to take it

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.