Sending multiple arguments to function..

This is a discussion on Sending multiple arguments to function.. within the C++ Programming forums, part of the General Programming Boards category; I need to have a function that gathers two INT's and a DOUBLE from the user, and then another function ...

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    26

    Sending multiple arguments to function..

    I need to have a function that gathers two INT's and a DOUBLE from the user, and then another function that takes those INT's and DOUBLE as arguments, and uses them in calculations to perform and send out via the COUT command. This has to be done without any encapsulation or data structuring.

    How do you gather 3 variables from one function, when everytime you run the function, it asks the same questions? Or can you gather all 3 at once, but then how do you send them out to another function in order?

    I did it using global variables, but I have to do it using arguments instead.

    thanks in advance.

    -Z

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,702
    Post the code you have thus far.
    Code:
    bool flip(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(1 << (value + 2))))
        .real() < 0;
    }

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    2,027
    Pass the arguments by reference:
    Code:
    void func(int &int1, int &int2, double &double1){
        //here changes to int1, int2 and double1 will effect their versions in the function calling this one.
    }
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  4. #4
    Registered User
    Join Date
    Jul 2008
    Posts
    26

    Reference variables..

    Quote Originally Posted by King Mir View Post
    Pass the arguments by reference:
    Code:
    void func(int &int1, int &int2, double &double1){
        //here changes to int1, int2 and double1 will effect their versions in the function calling this one.
    }
    That sounds about right, I'm going to try that.

    If I can't get it to work, I'll post the code that I have so far.

    thanks!

    -Z

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 02:07 AM
  2. Print function: sending a function.. through a function?
    By scarlet00014 in forum C Programming
    Replies: 3
    Last Post: 11-05-2008, 04:03 PM
  3. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  4. Bisection Method function value at root incorrect
    By mr_glass in forum C Programming
    Replies: 3
    Last Post: 11-10-2005, 08:10 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21