我似乎无法在我的代码中发现问题是我生病还是失明我不确定。我得到的错误是:
unresolved external symbol"struct MonthlyBudget_cdecl actual(void)" (?actual@@YA?AUMonthlyBudget@@XZ) referenced in function_main.
任何帮助都将不胜感激。
#include <iostream>
#include <string>
#include <Windows.h>
using namespace std;
struct MonthlyBudget {
double housing;
double utilities;
double householdExpenses;
double transportation;
double food;
double medical;
double insurance;
double entertainment;
double clothing;
double misc;
MonthlyBudget(double housingCost, double utilitiesCost, double householdExpensesCost, double transportationCost, double foodCost,
double medicalCost, double insuranceCost, double entertainmentCost, double clothingCost, double miscCost) {
housing = housingCost;
utilities = utilitiesCost;
householdExpenses = householdExpensesCost;
transportation = transportationCost;
food = foodCost;
medical = medicalCost;
insurance = insuranceCost;
entertainment = entertainmentCost;
clothing = clothingCost;
misc = miscCost;
}
MonthlyBudget() {
housing = 0;
utilities = 0;
householdExpenses = 0;
transportation = 0;
food = 0;
medical = 0;
insurance = 0;
entertainment = 0;
clothing = 0;
misc = 0;
}
void setHousing(double housingCost) {
housing = housingCost;
}
double getHousing() {
return housing;
}
void setUtilities(double utilitiesCost) {
utilities = utilitiesCost;
}
double getUtilities() {
return utilities;
}
void setHouseholdExpenses(double householdEXCost) {
householdExpenses = householdEXCost;
}
double getHouseholdExpenses() {
return householdExpenses;
}
void setTransportation(double transportationCost) {
transportation = transportationCost;
}
double getTransportation() {
return transportation;
}
void setFood(double foodCost) {
food = foodCost;
}
double getFood() {
return food;
}
void setMedical(double medicalCost) {
medical = medicalCost;
}
double getMedical() {
return medical;
}
void setInsurance(double insuranceCost) {
insurance = insuranceCost;
}
double getInsurance() {
return insurance;
}
void setEntertainment(double entertainmentCost) {
entertainment = entertainmentCost;
}
double getEntertainment() {
return entertainment;
}
void setClothing(double clothingCost) {
clothing = clothingCost;
}
double getClothing() {
return clothing;
}
void setMisc(double miscCost) {
misc = miscCost;
}
double getMisc() {
return misc;
}
};
int main() {
MonthlyBudget budget(500, 150, 65, 50, 250, 30, 100, 150, 75, 50);
MonthlyBudget actual();
double housing, utilities, householdExpenses, transportation, food, medical, insurance, entertainment, clothing, misc;
cout << "How much did you spend on housing?" << endl;
do {
cin >> housing;
actual().setHousing(housing);
} while (housing < 0);
cout << "How much did you spend on utilities?" << endl;
do {
cin >> utilities;
actual().setUtilities(utilities);
} while (utilities < 0);
cout << "How much did you spend on household expenses?" << endl;
do {
cin >> householdExpenses;
actual().setHousing(householdExpenses);
} while (householdExpenses < 0);
cout << "How much did you spend on transportation?" << endl;
do {
cin >> transportation;
actual().setTransportation(transportation);
} while (transportation < 0);
cout << "How much did you spend on food?" << endl;
do {
cin >> food;
actual().setFood(food);
} while (food < 0);
cout << "How much did you spend on medical?" << endl;
do {
cin >> medical;
actual().setMedical(medical);
} while (medical < 0);
cout << "How much did you spend on insurance?" << endl;
do {
cin >> insurance;
actual().setInsurance(insurance);
} while (insurance < 0);
cout << "How much did you spend on entertainment?" << endl;
do {
cin >> entertainment;
actual().setEntertainment(entertainment);
} while (entertainment < 0);
cout << "How much did you spend on clothing?" << endl;
do {
cin >> clothing;
actual().setClothing(clothing);
} while (clothing < 0);
cout << "How much did you spend on misc?" << endl;
do {
cin >> misc;
actual().setMisc(misc);
} while (misc < 0);
cout << "Showing projected budget compared to actual:" << endl;
cout << "Housing: " << budget.housing - actual().housing << endl;
cout << "Utilities: " << budget.utilities - actual().utilities << endl;
cout << "Household Expenses: " << budget.householdExpenses - actual().householdExpenses << endl;
cout << "Transportation: " << budget.transportation - actual().transportation << endl;
cout << "Food: " << budget.food - actual().food << endl;
cout << "Medical: " << budget.medical - actual().medical << endl;
cout << "Insurance: " << budget.insurance - actual().insurance << endl;
cout << "Entertainment: " << budget.entertainment - actual().entertainment << endl;
cout << "Clothing: " << budget.clothing - actual().clothing << endl;
cout << "Misc: " << budget.misc - actual().misc << endl;
string input;
cin >> input;
return 0;
}//main()
再次感谢您的帮助!我知道代码非常混乱,有更好的方法可以做到这一点,但对于我的生活,我现在想不出任何与我的流感有关的事。
答案 0 :(得分:0)
从actual()和所有提及中删除()。修正了程序。