Thread: Help in C++

  1. #1
    Nazma
    Guest

    Help in C++

    I am not sure how to enter a function prototype for a function named getPrices that will return a float value and has one float parameter (with a default of 10.00).
    Is there anyone that can help me out.

    Thanks

    Nazma

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    249
    The function prototype is the same as the function name except with a semicolen, ie:

    Code:
    getPrices(float poop); //prototype
    
    int main()
    {
         getPrices(poop); //call
       
         return 0;
    }
    
    getPrices(float poop) //function
    {
         return poop;
    }
    Please make more specific titles in future posts.
    Well, there are a few things wrong with your code:

    1) It does not work.
    2) It does not work.
    3) It does not work.

    Hope this helps.

  3. #3
    Registered User
    Join Date
    Oct 2002
    Posts
    291
    and with default value..

    Code:
    #include <iostream>
    
    using namespace std;
    
    float getPrice(float arg=10.0);
    
    int main()
    {
        cout << getPrice() << endl;
        system("PAUSE");
    }
    
    float getPrice(float arg)
    {
        return arg;
    }

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by Salem
    Ahhh - I love the smell of freshly baked homework in the morning....
    Seems like there's plenty of people willing to play chef, too.

    Anyways, what time zone are you in?

    @Nazma: A tutorial would be a good place to start.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed