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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:53:31+00:00 2026-06-04T17:53:31+00:00

What are the consequences (other than being poor code) of passing in a member

  • 0

What are the consequences (other than being poor code) of passing in a member item unnecessarily to a member function:

struct foobar
{
  char * arr; //properly initialized to SIZE at some point
}

class foo
{
  public:
    void bar(foobar&);
    foobar barfoo;
};


void foo::bar(foobar& barf)
{
    cin.get(barf.arr, SIZE, '\n');
    cin.ignore(100, '\n');
}

Is there any reason not to eliminate the parameters in bar altogether and just call barfoo directly? What are the consequences of NOT doing so, if any?

  • 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-04T17:53:32+00:00Added an answer on June 4, 2026 at 5:53 pm

    There is a slight overhead with passing the parameter, so if you will never call that method with another member, then you can get rid of the parameter. If you might need to do something like this in the future:

    class foo 
    { 
      public: 
        void bar(foobar&); 
    
      private/*(or still public)*/: 
        foobar barfoo;
        foobar barfoo2;
    
        void some_other_method() {
          //do stuff
          bar(barfoo);
          bar(barfoo2);
    }; 
    

    Then I would leave it alone.

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

Sidebar

Related Questions

What does <!DOCTYPE> describe other than the version of HTML being used and if
In OpenCL what will be the consequences and differences between the following struct declarations.
Are there any performance or other consequences for setting an object for key in
Will I suffer consequences later if I add FKs with ON DELETE CASCADE and
What are the consequences, (if any) not calling the conn.logoff() method after the following
What are the consequences (positive/negative) of using the unsafe keyword in C# to use
I'm wondering what could be some consequences of reusing the names of built-in types
I was wondering what the consequences are for compiling a class A with one
I've read a great deal of go from svn to git and other git-svn
While I continue to ponder this for the technical consequences that hitting 'compile' generates,

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.