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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:53:20+00:00 2026-05-22T21:53:20+00:00

Sometimes, for certain things like writing a line to a console, feels like something

  • 0

Sometimes, for certain things like writing a line to a console, feels like something that should be globally accessible to all objects. Something like:

writeError("UNHANDLED EXCEPTION",someData);

Also things such as math functions feel this way too. But how do you draw the line when doing this sort of thing becomes bad practice?

  • 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-22T21:53:21+00:00Added an answer on May 22, 2026 at 9:53 pm

    Some people draw the line at the point where the non-member function needs to be a friend of one of its arguments, so they use a lot of free functions.

    Some people draw the line at the point where the non-member function could reasonably be a member function of one of its arguments, even though it doesn’t actually use the class internals. They have somewhat fewer free functions.

    It’s usually best not to think of this as “becoming bad practice” – not all design in C++ is “properly” object-oriented. If your task is best solved by means other than OOP, then using OOP is itself “bad practice”. The argument how best to design your code can go on indefinitely in any language, but C++ doesn’t make any particular effort to steer you towards writing classes.

    See also:

    Effective C++ Item 23 Prefer non-member non-friend functions to member functions

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

Sidebar

Related Questions

I know that the compiler will sometimes initialize memory with certain patterns such as
Sometimes you need to skip execution of part of a method under certain non-critical
In C# I sometimes wish I could make special methods for certain instantiations of
Sometimes I have to work on code that moves the computer clock forward. In
Occasionally, when performing certain actions in Visual Studio, things seem to go 'haywire' -
I use Java builder pattern introduced by Joshua Bloch. Sometimes, I find certain fields
I have a listbox which (sometimes) uses OptionGroups as well, meaning that if I
Sometimes when I'm editing page or control the .designer files stop being updated with
Sometimes IE6 will render the text of a <ul> list the same color as
Sometimes I need to quickly extract some arbitrary data from XML files to put

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.