Find the answer to your Linux question:
Results 1 to 3 of 3
Plz tell me why i am getting this error? #include <iostream> #include <iomanip> using namespace std; double calcCommission (int quantity, double costEach, double discountPerCent, int orderMoreThan); int main ( ) ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2005
    Posts
    2

    Syntax error HELP plz!


    Plz tell me why i am getting this error?

    #include <iostream>
    #include <iomanip>
    using namespace std;

    double calcCommission (int quantity, double costEach, double discountPerCent, int orderMoreThan);
    int main ( )
    {
    int quantity;
    double costEach, discountPerCent, ifOrderMoreThan, total;
    cout<<"Enter the number of breakfasts ordered ";
    cin>>quantity;
    cout<<"Enter the number of lunches ordered ";
    cin>>quantity;
    cout<<"Enter the number of dinners ordered ";
    cin>>quantity;
    cout<<"Enter the cost of breakfast ";
    cin>>costEach;
    cout<<"Enter the cost of lunch ";
    cin>>costEach;
    cout<<"Enter the cost of dinner ";
    cin>>costEach;
    cout<<"Enter the discount percent for breakfast ";
    cin>>discountPerCent;
    cout<<"Enter the discount percent for lunch ";
    cin>>discountPerCent;
    cout<<"Enter the discount percent for dinner ";
    cin>>discountPerCent;
    total=calcCommission(int quantity,double costEach,double discountPerCent,int ifOrderMoreThan); <--- line 33
    return 0;

    pass5.cpp: In function `int main()':
    pass5.cpp:33: syntax error before `,' token

  2. #2
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    Code:
    total=calcCommission&#40;int quantity,double costEach,double discountPerCent,int ifOrderMoreThan&#41;; <--- line 33
    I haven't worked with c++ since college, so take this with a grain of salt.

    A couple (possible) problems I see:

    1. Since you've already declared the calcCommission() function and specified the variable types before main(), and you've already declared all your main() local variables that are function arguments, why are you including their type declarations in the calcCommission() function call?

    Should it not be:
    Code:
     total=calcCommission&#40;quantity, costEach, discountPerCent, ifOrderMoreThan&#41;;
    2. Where is calcCommission() actually defined? (I see where it's declared, but not defined.)

    Argh. Now I remember why this language drives me nuts. Even java is more friendly.

  3. #3
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,932
    Errr... this really is a simple error.

    Code:
    total=calcCommission&#40;int quantity,double costEach,double discountPerCent,int ifOrderMoreThan&#41;;
    you shouldn't have the type-specs in the function call these should be in the declaration only.
    Linux user #126863 - see http://linuxcounter.net/

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •