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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:09:57+00:00 2026-05-20T02:09:57+00:00

I might not even be posing the question correctly, but here’s my situation. I

  • 0

I might not even be posing the question correctly, but here’s my situation. I have a namespace into which I want to put all of my global functions. I want to define them all in the corresponding .cpp file. Many of these functions access instances of non-global classes, which may or may not be themselves members of the namespace. I can forward-declare the classes, but I will of course still get linker errors when I try to invoke the class methods. One (terrible-seeming) solution is to define each of these globals after the corresponding classes have been defined, but this puts different functions in different files and I want to avoid this at all costs, doing this seems deeply wrong.

What else can I do? I guess I’m having a conceptual issue here, what sort of design strategies might help resolve this? Do I have to make them static members of the corresponding classes? I don’t like this b/c my classes have long names but my namespace name is short… so just use a typedef? But conceptually these are global functions, so I would like to keep them that way… Thanks for your consideration.

  • 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-20T02:09:58+00:00Added an answer on May 20, 2026 at 2:09 am

    I can’t mark a comment as the answer, so I’ll just post it myself–basically Oli Charnesworth was right, refactoring was the solution. There was a particular class which was causing my circular dependencies problem, and I just redid things so that it no longer depended on the ‘global’ info, rather the ‘global’ info #included it.

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

Sidebar

Related Questions

This might not have a major usecase in projects, but I was just trying
The question might not be clear, so i will explain further. I saw some
The title might not explain my problem fully but I wasn't sure how to
Reading the documentation it seems this might not be possible, but it seems that
I've got another problem (which might not be an issue in terms of coding
Disclaimer I am well aware that PHP might not have been the best choice
Ok, the question might not be crystal clear. Let me give some details: Let's
My question might not be too correct... What I mean is: class MyClass {
I'm writing what might not even be called a language in python. I currently
I'm new to iPhone programming, so I might not even be using the correct

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.