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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:55:12+00:00 2026-05-10T23:55:12+00:00

What are the C++ coding and file organization guidelines you suggest for people who

  • 0

What are the C++ coding and file organization guidelines you suggest for people who have to deal with lots of interdependent classes spread over several source and header files?

I have this situation in my project and solving class definition related errors crossing over several header files has become quite a headache.

  • 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. 2026-05-10T23:55:13+00:00Added an answer on May 10, 2026 at 11:55 pm

    Some general guidelines:

    • Pair up your interfaces with implementations. If you have foo.cxx, everything defined in there had better be declared in foo.h.
    • Ensure that every header file #includes all other necessary headers or forward-declarations necessary for independent compilation.
    • Resist the temptation to create an ‘everything’ header. They’re always trouble down the road.
    • Put a set of related (and interdependent) functionality into a single file. Java and other environments encourage one-class-per-file. With C++, you often want one set of classes per file. It depends on the structure of your code.
    • Prefer forward declaration over #includes whenever possible. This allows you to break the cyclic header dependencies. Essentially, for cyclical dependencies across separate files, you want a file-dependency graph that looks something like this:
      • A.cxx requires A.h and B.h
      • B.cxx requires A.h and B.h
      • A.h requires B.h
      • B.h is independent (and forward-declares classes defined in A.h)

    If your code is intended to be a library consumed by other developers, there are some additional steps that are important to take:

    • If necessary, use the concept of ‘private headers’. That is, header files that are required by several source files, but never required by the public interface. This could be a file with common inline functions, macros, or internal constants.
    • Separate your public interface from your private implementation at the filesystem level. I tend to use include/ and src/ subdirectories in my C or C++ projects, where include/ has all of my public headers, and src/ has all of my sources. and private headers.

    I’d recommend finding a copy of John Lakos’ book Large-Scale C++ Software Design. It’s a pretty hefty book, but if you just skim through some of his discussions on physical architecture, you’ll learn a lot.

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

Sidebar

Related Questions

I have mail.py file: # coding: utf-8 from ..lib.common import * from ..lib.common import
I have this coding inside my java file . This code basically receives an
I use vim for coding. When I have to compile the current file, Currently
I am currently converting an xml file to java coding, but I have met
I have done coding public JSONResult media(HttpPostedFileBase file) { =====done with some code=== }
When coding a tag file, how to instruct caller to skip rest of the
I use the following coding which edits my text file based on the value
I am coding on a simple game and writing the *.xsd file. My Problem
I need to determin the byte size of a file. The coding language is
Before going all the hassle coding a generic asynchronous, queued, background running file download

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.