1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Questions regarding functions

Discussion in 'C' started by gabuchia, Oct 4, 2009.

  1. gabuchia

    gabuchia New Member

    Joined:
    Oct 4, 2009
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    Good day guys, this is my first time posting, so if there is anything I should know about this particular forum, please do let me know!

    I have tried searching on the internet, but do you guys know what does this line do?

    istringstream is(Expr);

    if(Expr.at(i)=='(') p++;

    return Value_Of_Expr(Expr.substr(0,i))+Value_Of_Expr(Expr.substr(i+1,Expr.length()-i-1));

    These three lines have something I don't understand, such as :

    istringstream is(XX) - What does it do?

    if(Exr.at(i)=='(') p++;

    return Value_Of_Expr(Expr.substr(0,i))+Value_Of_Expr(Expr.substr(i+1,Expr.length()-i-1));
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    When you post, there are posting guidelines, including how to post code. READ THEM PLEASE.
    They're not easy to miss.

    istringstream is(XX) creates an istringstream object named is, using a constructor that takes an XX as its argument, so it creates an istringstream from an XX.

    Code:
    if(Exr.at(i)=='(') p++;
    
    The brackets may be confusing you; let's add some space to clarify:
    Code:
    if(    Exr.at(i)  ==  '('    ) p++;
    
    So this calls Exr.at, passing in i, which returns a character, which the == compares with an open bracket. So this appears to be doing some kind of analysis of nested expressions where brackets are used for nesting.
     
  3. gabuchia

    gabuchia New Member

    Joined:
    Oct 4, 2009
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    Thank you for helping me out with that! I'm sorry I did not post a little chunk of code here because I thought if I could comprehend those few lines, I would be able to understand it.

    istringstream is(Expr);
    double value=0.0;
    is >> value;
    return value;


    thank you for helping me out with my little project here, I appreciate that!
     

Share This Page