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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:12:26+00:00 2026-05-26T00:12:26+00:00

I have been making files like this for awhile: Does the order make sense?

  • 0

I have been making files like this for awhile:
Does the order make sense? or should the namespace and the #includes be swapped and why.

#ifndef CLASSNAME_H // header guards
#define CLASSNAME_H

#include "a.h" // includes in alphabetical order
#include "b.h" // user specified includes first
#include "c.h"
#include <vector> // then library includes

namespace MyNamespace
{
    class ClassName
    {

    };
}

#endif
  • 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-26T00:12:26+00:00Added an answer on May 26, 2026 at 12:12 am

    Yes. That’s looks good.

    Though I order my headers differently (but alphabetically is fine).

    The only thing I would change is the include guard. I make the include my namspace as well as the class name. As several times I have classes with the same name (but in a different namespace) being used by the same code.

    #ifndef MY_COMPANY_MY_NAME_SPACE_MYCLASSNAME_H // header guards
    #define MY_COMPANY_MY_NAME_SPACE_MYCLASSNAME_H
    
    #include "a.h" //   includes in order of most specific to most general.
    
                   //   My includes first.
                   //   Then C++ headers          <vector>
                   //        I group all the containers together.
                   //   Then C specific headers   <sys/bla.h>
                   //   Then C generic headers    <ctype.h>
    
    
    namespace MyNamespace
    {
        Class ClassName
        {
    
        };
    }
    
    #endif
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have have been trying to make a validator for my xml files. I have
I have been making some research in the domain of servers for a website
For some time i have been making more or less little games. One level
I have been using the Rails console a fair bit lately and its making
I am making a game that needs a crosshair. I have been playing with
Have been working on this question for a couple hours and have come close
I have something like this: uses MSXML2_TLB; type TDocumentType = (dtOrder, dtInvoice, dtStatus, dtError);
I have been gathering information in this site and others about the best way
I've been trying to figure this out and make it work, but as I'm
I have a project I have been adding files to regularly and noticed recently

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.