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

  • Home
  • SEARCH
  • 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 4548830
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:16:31+00:00 2026-05-21T16:16:31+00:00

Homework, just advise please Apparently my idea of what returning something in a method

  • 0

Homework, just advise please

Apparently my idea of what returning something in a method does is wrong. I’m trying to write methods for getting derivatives of numbers and operations. So far I just wanted to get the derivative of a non-negative number that isn’t accompanied with an “x” (result should be zero no matter what value is given).

The code is pretty long and needs to be cleaned up so I’ll just include the method, the call, and what I’m getting.

Method:

int noXDerivative(int tempInt, string tempX)
{
    if (tempX == "")
    {
        tempInt = 0;
    }
    return tempInt;
}

void getDerivatives(int tempInt, string tempX, int tempInt2, string tempX2, char tempOperator)
{
    noXDerivative(tempInt, tempX);
    noXDerivative(tempInt2, tempX2);
}

The call:

getDerivatives(tempNumInt, tempNumX, tempNum2Int, tempNum2X, expression[iterator]);

I also called the “noXDerivative” directly to see what would happen but the result didn’t change. The test I’m running right now is “5 + 6” (tempNumInt is 5 and tempNum2Int is 6). I keep getting 11 when I need to get 0 (again, there are no “x”s). I was hoping that if I put tempNumInt as one of the parameters it would be changed from 5 to 0 within the noXDerivative method but it doesn’t. How do I correct this?

  • 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-21T16:16:32+00:00Added an answer on May 21, 2026 at 4:16 pm

    I have to say that I don’t understand what it is that you’re trying to do.

    Nevertheless, to achieve your goal of modifying tempInt inside getDerivatives(), you can either do:

    tempInt = noXDerivative(tempInt, tempX);
    

    Or, you can modify the noXDerivative() function to take its argument by reference, rather than by value:

    int noXDerivative(int &tempInt, string tempX)
    {
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to solve this problem, its not a homework question, its just code
I got this exercise, is not a homework , I just trying to solve:
This is not a homework question, just something at work that's bugging me. I'm
I promise this isn't homework. I'm just a curious novice. How does this: function
I just got a homework assignment, and it's just creating a linear search algorithm
this one is not homework, it just the fact that i've been out of
(This is no homework and no work issue. It's just my personal interest/occupation and
this is a homework which I already did, I just need either confirmation if
I have a question about my C++ homework. I am just confused about *this.
I have an issue and NO it is not homework, it's just a programmer

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.