مرسی اون مشکل حل شد ولی باز ارور میده :
code:#include <iostream>
#include <fstream>
void CalcPay(float,float,float&);
const float MAX_HOURS = 40.0;
const float OVERTIME = 1.5;
int main(){
float payRate;float hours;float wages;float total;int empNum;ofstream payFile;
payFile.open("payfile.dat");
total = 0.0;
cout << "enter employee number: ";
cin >> empNum;
while (empNum != 0){
cout << "enter pay rate: ";cin >> payRate;
cout << "enter hours worked: ";cin >> hours;
CalcPay(payRate,hours,wages);
total = total + wages;
payFile << empNum << payRate << hours << wages;
cout << "enter employee number: ";cin >> empNum;
}
cout << "total payroll is " << total << endl;
return 0;
}
void CalcPay(/* in */ float payRate,/* in */ float hours,/* in */ float wages){
if (hours > MAX_HOURS) wages = (MAX_HOURS * payRate) + (hours - MAX_HOURS) * payRate * OVERTIME;
else wages = hours * payRate;
}
error:start.cpp: In function ‘int main()’:
start.cpp:7:62: error: ‘ofstream’ was not declared in this scope
start.cpp:7:62: note: suggested alternative:
In file included from /usr/include/c++/4.7/ios:39:0,
from /usr/include/c++/4.7/ostream:40,
from /usr/include/c++/4.7/iostream:40,
from start.cpp:1:
/usr/include/c++/4.7/iosfwd:162:34: note: ‘std::ofstream’
start.cpp:7:71: error: expected ‘;’ before ‘payFile’
start.cpp:8:1: error: ‘payFile’ was not declared in this scope
start.cpp:10:1: error: ‘cout’ was not declared in this scope
start.cpp:10:1: note: suggested alternative:
In file included from start.cpp:1:0:
/usr/include/c++/4.7/iostream:62:18: note: ‘std::cout’
start.cpp:11:1: error: ‘cin’ was not declared in this scope
start.cpp:11:1: note: suggested alternative:
In file included from start.cpp:1:0:
/usr/include/c++/4.7/iostream:61:18: note: ‘std::cin’
start.cpp:20:41: error: ‘endl’ was not declared in this scope
start.cpp:20:41: note: suggested alternative:
In file included from /usr/include/c++/4.7/iostream:40:0,
from start.cpp:1:
/usr/include/c++/4.7/ostream:562:5: note: ‘std::endl’