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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:28:42+00:00 2026-05-26T15:28:42+00:00

I just have a few general questions about keeping code clean and readable. 1)

  • 0

I just have a few general questions about keeping code clean and readable.

1) Should functions have separate files from main (prototypes and initialization) ? (the functions are long)

2) If functions do have separate files, in Main do I include the function prototypes or the function initializations?

3) Are global variables in main shared across all files in the project? If not, how would I make it so the variable has access by all files?

4) If I include functions, when I use #include do I keep the function file names in <> or ""? When would I use each one?

5) When including a function, do I just include its name, or its full address? (I am using Code Blocks). For example, if I am including a function file called calculate.hpp, would I do #include "calculate.hpp" or #include "Users\Me\My Documents\calculate.hpp"?

  • 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-26T15:28:42+00:00Added an answer on May 26, 2026 at 3:28 pm

    Lots of questions!

    1) Should functions have separate files from main (prototypes and initialization) ? (the functions are long)

    Simplistically speaking:

    • Declarations go in the header file (.h)
    • Definitions go in the source file (.cpp)

    If “the functions are long”, consider how you can shorten them. Since you ask about keeping code clean, I recommend Clean Code: A Handbook of Agile Software Craftsmanship by Robert C. Martin, which talks about this at length.

    2) If functions do have separate files, in Main do I include the function prototypes or the function initializations?

    You should only ever #include header files.

    3) Are global variables in main shared across all files in the project? If not, how would I make it so the variable has access by all files?

    Global variables should be the exception rather than the rule. However, see my earlier point about declaration and definition.

    4) If I include functions, when I use #include do I keep the function file names in <> or “”? When would I use each one?

    You’re #include-ing a whole file, not just a function.

    • Use <> for system-wide headers, such as those in the standard library
    • "" for local headers, such as your own calculate.hpp.

    5) When including a function, do I just include its name, or its full address? (I am using Code Blocks). For example, if I am including a function file called calculate.hpp, would I do #include “calculate.hpp” or #include “Users\Me\My Documents\calculate.hpp”?

    Use relative paths (with forward-slashes where necessary), never absolute paths. Consider what happens when someone else tries to build your code.

    I recommend checking out some open-source C++ projects on SourceForge or GitHub to see how they’re laid-out.

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

Sidebar

Related Questions

Im a newbie PHP programmer and I have a few questions about creating a
I have just started programming and have made a few small applications in C
I have just started learning NHibernate. Over the past few months I have been
I have a File having text and few numbers.I just want to extract numbers
I have several database tables that just contain a single column and very few
I'm just starting with programming. I have a list of a few strings and
I just have a quick question about how to get the length of a
A few general questions to those who are well-versed in developing web-based applications. Question
I just have started to learn Haskell and combine reading books and tutorials with
I just have an XP machine, and i want to play around using CC.NET.

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.