[英]C++ Problem: [Error] statement cannot resolve address of overloaded function x2
我是一個需要幫助的完整菜鳥。 希望有經驗的各位大俠幫幫我。
非常感謝任何輸入。
由於代碼太長,以下是代碼的運行方式:
#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;
}
d.payslipdetails 和 d.displaydetails 中存在錯誤。 我希望這比我上一篇文章更清楚!
錯誤是:[Error] 語句無法解析重載函數的地址
我不知道該怎么做...
您是否可能嘗試在對象d
上調用方法? 那么你至少需要添加括號。 至於每個函數調用:
d.payslipdetails();
檢查方法名稱 paySlipDetails(); 根據 Payslip 類的實現代碼提供任何必需的參數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.