too many arguments in function call  
  May 16, 2023 at 4:55am UTC  
 
it is related to the calculator class that ive made 
error at line 117
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 
  #include <iostream> 
using  namespace  std;
class  calculator{
    public :
    double  n[];
    void  alldata(double  num1, double  num2){
        n[0] = num1;
        n[1] = num2;
    }
    double  addition(){
        return  n[0] + n[1];
    }
    double  substraction(){
        return  n[0] - n[1];
    }
    double  division(){
        return  n[0] / n[1];
    }
    double  multiplication(){
        return  n[0] * n[1];
    }
};
class  database{
    private :
    int  choice;
    string acc,pass;
    public :
    void  menu();
    void  addingacc();
    void  viewacc();
};
void  database::menu(){
    //Authentication 
    string logging = "gabbz29" ;
    int  pass = 387025;
    cout << "Enter your account name: " ;
    cin >> logging;
    cout << "Enter your password: " ;
    cin >> pass;
    while (!(logging == "gabbz29"  || pass == 387025)){
        cout << "\nCheck the information that you provided and try again.\n" ;
        cin.clear();
        cin.ignore(100 , '\n' );
        cout << "Enter your account name: " ;
        cin >> logging;
        cout << "Enter your password: " ;
        cin >> pass;
    }
    //Database menu 
    cout << "--------------Database Menu--------------\n" ;
    cout << "1.Add an account.\n" ;
    cout << "2.View your accounts.\n" ;
    cout << "3.Delete an existing account.\n" ;
    cout << "4.Modify an account.\n" ;
    cout << "5.Exit.\n" ;
    cout << "6.Go back to menu.\n" ;
    cout << "Press your transaction: " ;
    cin >> choice;
    while (!(choice == 1 || choice == 2 || choice == 3 || choice == 4 || choice == 5 || choice == 6)){
        cout << "Only choose between number's 1-6.\n" ;
        cout << "Try again: " ;
        cin.clear();
        cin.ignore(100 , '\n' );
        cin >> choice;
    }
    if (choice == 1){
        addingacc();
    }else  if (choice == 2){
        viewacc();
    }else  if (choice == 5){
        exit;
    }
}
void  database::addingacc(){
    cout << "----------------Adding section----------------\n" ;
    cout << "E-mail/G-gmail/Username: " ;
    cin >> acc;
    cout << "Enter password: " ;
    cin >> pass;
}
void  database::viewacc(){
        
}
int  main(){
    char  chc;
    cout << "---------------------------------------------ALL IN ONE SOFTWARE---------------------------------------------\n" ;
    cout << "A.Software saving.\n" ;
    cout << "B.Calcaulator.\n" ;
    cout << "C.General Weighted Average Calculator.\n" ;
    cin >> chc;
    
    if (chc == 'A'  || chc == 'a' ){ 
    database alldata;
    alldata.menu();
    }else  if (chc == 'b'  || chc == 'B' ){
        char  opt;
        do {
        double  num[2];
        cout << "---------------------AIO Calculator---------------------\n" ;
        cout << "Enter two digits: " ;
        cin >> num[0] >> num [1];
        calculator cal;
        cal.addition(num[0],num[1]);
        cout  << "Use it again or go back to main Menu?\n [Y] to use it again\n [N] to exit\n [C] to go back to Main menu." ;
        cin >> opt;
        while (!(opt == 'y'  || opt == 'Y'  || opt == 'n'  || opt == 'N'  || opt == 'c'  || opt == 'C' )){
            cout << "Only choose between [Y/N/C]\n" ;
            cin.clear();
            cin.ignore(100 , '\n' );
            cout << "Y = continue. N = exit. C = Back to main menu: " ;
            cin >> opt;
        }
        if (opt == 'c'  || opt == 'C' ){
            
        }
        }while (opt == 'y'  || opt == 'Y' );
    }
}
 
 
Last edited on May 16, 2023 at 4:56am UTC  
 
 
 
 
  May 16, 2023 at 5:14am UTC  
 
Line 117 calls a function with 2 arguments. 
Line 13ff defines a function with zero arguments. 
 
2 is not equal to 0.
 
 
 
 
  May 16, 2023 at 5:58am UTC  
 
For some reason you pass the data to alldata(...) not addition(...). 
 
Line 6 unfortunately compiles (it should at least warn) but is invalid. 
The lines 9/10 causes undefined behavior because n  has no size.
 
 
 
 
  May 16, 2023 at 7:54am UTC  
 
thank you all guys 
 
 
 
 
  May 16, 2023 at 8:42am UTC  
 
calculator class could have a constructor that takes 2 args and sets n from them. 
 
L69 - this could be coded using < || > rather than having tests for each specific correct value. 
 
Also for cases where you input a choice and then process depending upon the choice a switch statement is often used. The default case being used for input error. 
 
 
 
 
  May 16, 2023 at 3:11pm UTC  
 
Check your Boolean logic in line 49.  That should be &&, not ||. 
 
 
 
Topic archived. No new replies allowed.