返回0之前找到文件的末尾 [英] end of file found before return 0
本文介绍了返回0之前找到文件的末尾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好吧,这是一个使用类创建函数的功能.
我到此为止了,但它总是说返回之前找到了文件结尾.
我看不到问题,在这里没有任何帮助,将不胜感激.
Ok, this is a wadge caculation that uses a class to create the functions.
I got this far but it keeps saying end of file found before return.
I can not see the problem any help here would be appreciated.
#include <iostream>
#include <string>
using namespace std;
class employee {
private:
const static int MAX_HOURS = 40 ;
string firstName;
string lastName;
int hours[MAX_HOURS];
int numhours;
int wadges;
public:
// First Name
string getFirstName() { return firstName; }
void setFirstName(string name) { firstName = name; }
void retrieveFirstName() {
string emp;
cout << "First Name: ";
cin >> emp;
setFirstName(emp);
}
// Last Name
string getLastName() { return lastName; }
void setLastName(string name) { lastName = name; }
void retrieveLastName() {
string emp;
cout << "Last Name: ";
cin >> emp;
setLastName(emp);
}
// Num hours
int getnumhours() { return numhours; }
void setnumhours(int hours) {
if (hours >= 0 && hours <= MAX_HOURS) {
numhours = hours;
} else {
numhours = 0;
}
}
void retrievenumhours() {
cout << "How many hours did you work? ";
int thours;
cin >> thours;
setnumhours(thours);
}
// Wadges
int getwadges() {return wadges;}
void setwadges (int twadges){
wadges = twadges;
setwadges(twadges);
}
void retrievewadges() {
cout << "Wadges per hour ? ";
int wadges;
cin >> wadges;
setwadges(wadges);
}
void retrieve() {
retrieveFirstName();
retrieveLastName();
retrievenumhours();
retrievewadges();
}
double calwadges() {
double total = 0;
for (int i = 0; i < getnumhours(); i ++) {
total += hours[i];
};
int main() {
employee name ;
name.retrieve();
system("pause");
return 0;
}
推荐答案
您忘了在课程结束时关闭"(带有}"字符)calwadge函数.
You forgot to "close" (with a ''}'' character) the calwadge function at the end of your class.
检查最后一个for循环.您错过了一个}.
check with your last for loop. you missed a } there.
这篇关于返回0之前找到文件的末尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文