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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:44:50+00:00 2026-06-07T05:44:50+00:00

Our C++ professor mentioned that using the result of operator-> as input into another

  • 0

Our C++ professor mentioned that using the result of operator-> as input into another operator-> is considered bad style.

So instead of writing:

return edge->terminal->outgoing_edges[0];

He would prefer:

Node* terminal = edge->terminal;
return terminal->outgoing_edges[0];
  1. Why is this considered bad style?
  2. How could I restructure my program to avoid the ‘bad style’ but also avoid the extra line of code that is created as per the above suggestion?
  • 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-07T05:44:51+00:00Added an answer on June 7, 2026 at 5:44 am

    You should ask your professor as to why he considers it bad style. I don’t. I would however consider his omission of the const in the declaration of terminal to be bad style.

    For a single snippet like that, it’s probably not bad style. However consider this:

    void somefunc(Edge *edge)
    {
       if (edge->terminal->outgoing_edges.size() > 5)
       {
            edge->terminal->outgoing_edges.rezize(10);
            edge->terminal->counter = 5;
       }
       ++edge->terminal->another_value;
    }
    

    This is starting to get unwieldy – it is difficult to read, it is difficult to write (I made approximately 10 typos when typing that). And it requires a lot of evaluation of the operator-> on those 2 classes. OK if the operator is trivial, but if the operator does anything exciting, it’s going to end up doing a lot of work.

    So there’s 2 possible answers:

    1. Maintanability
    2. Efficiency

    And a single snippet like that, you can’t avoid the extra line. In something like the above, it’d have resulted in less typing.

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

Sidebar

Related Questions

Our OS professor mentioned that for assigning a process id to a new process,
In my work with my professor I have to ssh into our server and
My professor, (for some unexplained reason) wants to change all input-output files of our
Our professor required us to check if a word is a palindrome by using
Recently, our professor stated that our presentation layer should consist of mostly method calls
Our application is a Java-GWT application that uses Guice-Persist and Guice-Servlet extensively. We have
I was given some code by our professor with some things I have never
OK, our professor explained (kinda) this problem, but it still doesn't make much sense.
I'm using a new work computer that has an old sdk, Java 1.3.1, on
I've taken 2 OOP C# classes, but now our professor is switching over to

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.