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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:04:38+00:00 2026-05-15T06:04:38+00:00

In C++ one can have a ‘GLOBAL FUNCTION’, which means it does not belong

  • 0

In C++ one can have a ‘GLOBAL FUNCTION’, which means it does not belong to any class. I wondered if that isn’t just a violation of the basic principles of OOP?

What would be the difference with using a global function or function that is static in a class? I’m thinking the latter is more OOP oriented. But I may be wrong however…

Does it not make it harder when writing a multithreaded applicaton?

  • 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-15T06:04:38+00:00Added an answer on May 15, 2026 at 6:04 am

    A static function inside a class is as OO as a global function inside a module. The thing is in JAVA, you don’t have the choice.

    In C++, you can encapsulate your global functions inside namespaces, you don’t need a dummy class to do this. This way you have modularity.

    So of course you can put functions outside namespaces this way you have really global functions. But that’s not very different from a JAVA kitchen sink class with a bunch of static functions. It’s also bad code, but can be just ok for small projects 🙂

    Also in C++ you have a lot of choices to have “global” function that actually are linked to a class, as operator functions, that may be for instance friends of a class.

    EDIT
    As for multithreading, you have to worry about global variables, not functions.

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

Sidebar

Related Questions

interfaces provide a useful abstraction capability. One can have a class Foo implement some
Can any one tell me an opensource js library that can have a real-time
One can say a type parameter T must have a specific supertype S_1: class
I have a Vote class and one of the properties it can have is
With C++, I can have one class definition in a header file, and have
Two class: Department Task One department can have many tasks. One task can only
Let's say I have 3 divs each with class item and only one can
Any one can tell me what means Courtesy limit, such as like 1000 queries
I have two tables user and email. One user can have multiple emails so
How can one have more than a Wizard control on the same page without

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.