简体   繁体   中英

C++ Problem: [Error] statement cannot resolve address of overloaded function x2

I'm a complete noob here in need of help. I'm hoping you guys, who are more experienced than me, can help me out.

Any input is greatly appreciated.

Here is how the code is supposed to go since it's too long:

#include <iostream>
    
    using namespace std;
    
    class Payslip
    {
    
    string name, pay_grade;
    float salary, oth, otp, gross, net, tax, sss, pagibig, philhealth;
    
    public: 
    void payslipdetails()
    {
    
    // Extremely long, but this part of the code would allow me to allow user to input their names, their base salary, and overtime hours.
    
    sss = 500;
    pagibig = 200;
    philhealth = 100;
    otp = oth * (salary*0.01);
    gross = salary + otp;
    net = gross - (tax + sss + pagibig + philhealth);
    
    // then a series of if/else if condition if salary is greater/less than or equals to, and we divide the said salaries into pay grade A or B. 

/* Example: 
                if (salary >= 10000 && salary <= 19999)
                {
                    // Pay grade A
                    if (salary >= 10000 && salary <= 14999) 
                    {
                    pay_grade = "A";
                    }
                    
                        // Pay grade B
                        else if (salary >= 15000 && salary <= 19999)
                        {
                            pay_grade = "B";
                        }
                    tax = gross * 0.10;
                }*/
                
    
    }
    }
    
    void display_details()
    {
    cout<<"\n Employee Name              : " << name;
                    cout<<"\n Basic Salary               : " << salary;
                    cout<<"\n Pay Grade                  : " << pay_grade;
                    cout<<"\n No. of OT hours            : " << oth;
                    cout<<"\n OT Pay                     : " << otp;
                    cout<<"\n Gross Pay                  : " << gross;
                    cout<<"\n Withholding Tax            : " << tax;
                    cout<<"\n Net Pay                    : " << net;
            }
    };
    int main()
    {
            Payslip d;
            d.payslipdetails;
            d.display_details;
            return 0;
    }

There is an error in d.payslipdetails and d.displaydetails. I hope this is more clear than my last post!

The error is: [Error] statement cannot resolve address of overloaded function

I'm not sure how to do this...

Are you possibly trying to call a method at the object d ? Then you need at least add parentheses. as for each function call:

    d.payslipdetails();

Check the method name paySlipDetails(); provide any requred parameters as per implementation code of Payslip class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM