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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:07:33+00:00 2026-06-02T15:07:33+00:00

I currently have a project with 3 files. One DBheader.h header file that includes:

  • 0

I currently have a project with 3 files.

One DBheader.h header file that includes:

  • Class declarations (with their smaller member function definitions)

A DBdefinitions.cpp file with:

  • Larger member function definitions for the classes in DBheader.h

and finally a DBmain.cpp file that contains:

  • Main code
  • Some large (non-memeber) functions that use the classes defined in DBheader.h

I would preferably like to move these functions somewhere to make my DBmain.cpp file less cluttered. Should/could I move them to the DBdefinition.cpp file or do I need to create a new separate .cpp file for non-member functions?

Here’s a rough of what my code looks like if the above is unclear.

//DBheader.h

//libraries..

class course{
//member data..

void printinfo();

}

–

//DBdefinitions.cpp

#include "DBheader.h"
void course::printinfo(){/*do stuff*/}

–

//DBmain.cpp

#include "DBheader.h"
typedef map<int,course> record;
void fileinput(record &map);
int main(){
//stuff
}
void fileinput(record &map){
//lots of code
}
  • 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-06-02T15:07:36+00:00Added an answer on June 2, 2026 at 3:07 pm

    You should organize free functions that are part of the public interface in a similar fashion you used for the class definition: a header with the declaration and an implementation file with the implementations.

    If they are particular to a specific translation unit, keep them in that implementation file.

    All free functions should be declared inside a namespace (named for the public ones, anonymous for “private” free functions).

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

Sidebar

Related Questions

I currently have the following models/toy.rb file in my RoR project: class ToysPurchased include
Currently I have a simple maven project that is building a jar file and
I currently have a file abc.htm in my Custom Server Control Project and it's
I currently have the following in one solution: Core Project (data access, biz logic,
I have a project that needs to be done using ASP.NET. Currently, I'm using
I currently have a pre-commit hook in my mercurial project that gives the user
We have a setup project that currently adds Project Output's from different visual studio
We currently have avi-files that contain MP3-streams. We noticed that our provider cannot ensure
Currently I have a C# solution that contains a class library, installer, and setup
Background: Custom workflow activities for Microsoft Dynamics CRM. Currently we have one project per

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.