Thread: Sending multiple arguments to 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,708
    Post the code you have thus far.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    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, 03:07 AM
  2. Print function: sending a function.. through a function?
    By scarlet00014 in forum C Programming
    Replies: 3
    Last Post: 11-05-2008, 05: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, 09:10 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM