Oct 13, 2012 at 8:40pm UTC
can someone tell me what to use instead of include stdafx.h, when l build it gives me error c1083 saying cant open file directory. pls check it for me
#include "stdafx.h"
#include <iostream>
#include <cstring>
#include <iomanip>
#include <string>
using namespace std;
class Employee
{
string name;
int employeetype;
string vacationdaysused;
string sickdaysused;
public:
Employee()
{
name=" ";
employeetype=0;
vacationdaysused=" ";
sickdaysused=" ";
}
void settype(string TYPE )
{
TYPE=type;
}
void setemployeetype (int type){TYPE =employeetype;}
{
TYPE=employeetype;
}
void setvacationdayused (string VACATION)
{
VACATION=vacation;
}
void setsickdaysused(string SICKDAYS)
{
SICKDAYS=sickdaysused;
}
string gettype()
{
return (type);
}
int getemployeetype()
{
return(employeetype);
}
string getvacationdaysused()
{
return(vacationdays);
}
string getsickdays()
{
return (sickdays);
}
void show_record();
};
void Employee::show_record()
{
cout << "Employeetype " << getemployeetype()<<endl;
cout << "EMPLOYEE " << getemployeetype()<<endl;
cout << "Vacation" << getvacationdayused()<<endl;
cout << "Sick" << getsickdaysused()<<endl;
}
int main()
{
const int SIZE=3;
Employee employee[SIZE];
string EMPLOYEE;
int TYPE;
string ;VACATION
string SICK;
for (int i=0; i<SIZE;i++)
{
cout << "Enter the Employee type : " << endl;
cin>>TYPE;
employee[i].settype(TYPE);
cout << "Enter the Employees type: " << endl;
cin >> TYPE;
employee[i].setemployeetype(type);
cout << "Enter the Employees Vacation days used: " << endl;
cin>>VACATION;
employee[i].setvacationdays(VACATION);
cout << "Enter the Employees SICK: " << endl;
cin>>SICK;
employee[i].setsickdays(SICK);
}
for (int i=0;i<SIZE;i++)
employee[i].show_record();
system ("pause");
return 0;
}
Oct 14, 2012 at 6:48pm UTC
if you are not using VS on Windows then try commenting that line. stdafx is VS specific header.
Oct 14, 2012 at 6:51pm UTC
l am using window visual 2008, and please i don't understand when you said l should put my code in the code tags.
your response would be appreciated
thanks
Oct 15, 2012 at 12:15pm UTC
Try removing the stdafx anyway and see if it works(otherwise post back then the solution will be somewhat complex)
Post code encased in code tags as Pickle Gunner has done for you.
Use the "<>" symbol on the format menu
Oct 15, 2012 at 8:50pm UTC
thanks l did both, it did not build, still saying same error
Oct 15, 2012 at 10:20pm UTC
You have a number of problems in your code:
1) Lines 24, 28, 32, 26. In each of you setter functions, you have the left and right side of the assignment statement reversed.
2) Line 26. You have the body of the function twice.
3) Line 40. type is not a member of the class.
4) Are type and employeetype the same or different. If the same, you have two different setter functions for the same variable. If the different, then type is not defined.
5) Line 48. vacationsdays does not match the declaration. Should be vacationdaysused.
6) Line 69. Extraneous semicolon after string.
7) Line 60: getvacationdayused() is misspelled.
8) Line 61: Again fuction call does not match declaration in class.
9) Line 68: type is declared as int. You're trying to pass it to a function taking a string.
10) Line 78: same issue.
11) Line 81: Function call does not match declaration in class.
12) Line 84: Same issue.
BTW, I had no problem ccompiling without stdafx.h
Last edited on Oct 15, 2012 at 10:31pm UTC
Oct 15, 2012 at 10:58pm UTC
//employee.cpp
#include <iostream>
#include <cstring>
#include <iomanip>
#include <string>
using namespace std;
class Employee
{
string name;
int employeetype;
string vacationdaysused;
string sickdaysused;
public:
Employee()
{
name=" ";
employeetype=0;
vacationdaysused=" ";
sickdaysused=" ";
}
void settype(string TYPE )
{
TYPE=type;
}
void setemployeetype;
{
TYPE=employeetype;
}
void setvacationdayused (string VACATION)
{
VACATION=vacation;
}
void setsickdaysused(string SICKDAYS)
{
SICKDAYS=sickdaysused;
}
string gettype()
}
int getemployeetype()
{
return(employeetype);
}
string getvacationdaysused()
{
return(vacationdaysused);
}
string getsickdays()
{
return (sickdays);
}
void show_record();
};
void Employee::show_record()
{
cout << "Employeetype " << getemployeetype()<<endl;
cout << "EMPLOYEE " << getemployeetype()<<endl;
cout << "Vacation" << getvacationdayused()<<endl;
}
int main()
{
const int SIZE=3;
Employee employee[SIZE];
string EMPLOYEE;
TYPE;
string VACATION
string SICK;
for (int i=0; i<SIZE;i++)
{
cout << "Enter the Employee type : " << endl;
cin>>TYPE;
employee[i].settype(TYPE);
cout << "Enter the Employees type: " << endl;
cin >> TYPE;
setemployeetype(type);
cout << "Enter the Employees Vacation days used: " << endl;
cin>>VACATION;
cout << "Enter the Employees SICK: " << endl;
cin>>SICK;
}
for (int i=0;i<SIZE;i++)
employee[i].show_record();
system ("pause");
return 0;
}
i did what you said but can not build with and without the stdafx.h, now its giving me 25errors. thanks for reply. pls can you help me further
Oct 16, 2012 at 2:04am UTC
#include "stdafx.h"
#include <iostream>
#include <cstring>
#include <iomanip>
#include <string>
using namespace std;
class Employee
{
string name;
int employeetype;
string vacationdaysused;
string sickdaysused;
public:
Employee()
{
name=" ";
employeetype=0;
vacationdaysused=" ";
sickdaysused=" ";
}
void settype(string TYPE )
{
TYPE=type;
}
void setemployeetype (int type){TYPE =employeetype;}
{
TYPE=employeetype;
}
void setvacationdayused (string VACATION)
{
VACATION=vacation;
}
void setsickdaysused(string SICKDAYS)
{
SICKDAYS=sickdaysused;
}
string gettype()
{
return (type);
}
int getemployeetype()
{
return(employeetype);
}
string getvacationdaysused()
{
return(vacationdays);
}
string getsickdays()
{
return (sickdays);
}
void show_record();
};
void Employee::show_record()
{
cout << "Employeetype " << getemployeetype()<<endl;
cout << "EMPLOYEE " << getemployeetype()<<endl;
cout << "Vacation" << getvacationdayused()<<endl;
cout << "Sick" << getsickdaysused()<<endl;
}
int main()
{
const int SIZE=3;
Employee employee[SIZE];
string EMPLOYEE;
int TYPE;
string ;VACATION
string SICK;
for (int i=0; i<SIZE;i++)
{
cout << "Enter the Employee type : " << endl;
cin>>TYPE;
employee[i].settype(TYPE);
cout << "Enter the Employees type: " << endl;
cin >> TYPE;
employee[i].setemployeetype(type);
cout << "Enter the Employees Vacation days used: " << endl;
cin>>VACATION;
employee[i].setvacationdays(VACATION);
cout << "Enter the Employees SICK: " << endl;
cin>>SICK;
employee[i].setsickdays(SICK);
}
for (int i=0;i<SIZE;i++)
employee[i].show_record();
system ("pause");
return 0;
}
Pls dont be annoyed with me, l just going nut, was trying to figure out what is insert code as lm here for only a week now still new pls. l did what you asked hope l did the right thing. just came back from class and saw it.
Oct 16, 2012 at 2:06am UTC
#include "stdafx.h"
#include <iostream>
#include <cstring>
#include <iomanip>
#include <string>
using namespace std;
class Employee
{
string name;
int employeetype;
string vacationdaysused;
string sickdaysused;
public:
Employee()
{
name=" ";
employeetype=0;
vacationdaysused=" ";
sickdaysused=" ";
}
void settype(string TYPE )
{
TYPE=type;
}
void setemployeetype (int type){TYPE =employeetype;}
{
TYPE=employeetype;
}
void setvacationdayused (string VACATION)
{
VACATION=vacation;
}
void setsickdaysused(string SICKDAYS)
{
SICKDAYS=sickdaysused;
}
string gettype()
{
return (type);
}
int getemployeetype()
{
return(employeetype);
}
string getvacationdaysused()
{
return(vacationdays);
}
string getsickdays()
{
return (sickdays);
}
void show_record();
};
void Employee::show_record()
{
cout << "Employeetype " << getemployeetype()<<endl;
cout << "EMPLOYEE " << getemployeetype()<<endl;
cout << "Vacation" << getvacationdayused()<<endl;
cout << "Sick" << getsickdaysused()<<endl;
}
int main()
{
const int SIZE=3;
Employee employee[SIZE];
string EMPLOYEE;
int TYPE;
string ;VACATION
string SICK;
for (int i=0; i<SIZE;i++)
{
cout << "Enter the Employee type : " << endl;
cin>>TYPE;
employee[i].settype(TYPE);
cout << "Enter the Employees type: " << endl;
cin >> TYPE;
employee[i].setemployeetype(type);
cout << "Enter the Employees Vacation days used: " << endl;
cin>>VACATION;
employee[i].setvacationdays(VACATION);
cout << "Enter the Employees SICK: " << endl;
cin>>SICK;
employee[i].setsickdays(SICK);
}
for (int i=0;i<SIZE;i++)
employee[i].show_record();
system ("pause");
return 0;
}
Oct 16, 2012 at 2:16am UTC
#include "stdafx.h"
#include <iostream>
#include <cstring>
#include <iomanip>
#include <string>
using namespace std;
class Employee
{
string name;
int employeetype;
string vacationdaysused;
string sickdaysused;
public:
Employee()
{
name=" ";
employeetype=0;
vacationdaysused=" ";
sickdaysused=" ";
}
void settype(string TYPE )
{
TYPE=type;
}
void setemployeetype (int type){TYPE =employeetype;}
{
TYPE=employeetype;
}
void setvacationdayused (string VACATION)
{
VACATION=vacation;
}
void setsickdaysused(string SICKDAYS)
{
SICKDAYS=sickdaysused;
}
string gettype()
{
return (type);
}
int getemployeetype()
{
return(employeetype);
}
string getvacationdaysused()
{
return(vacationdays);
}
string getsickdays()
{
return (sickdays);
}
void show_record();
};
void Employee::show_record()
{
cout << "Employeetype " << getemployeetype()<<endl;
cout << "EMPLOYEE " << getemployeetype()<<endl;
cout << "Vacation" << getvacationdayused()<<endl;
cout << "Sick" << getsickdaysused()<<endl;
}
int main()
{
const int SIZE=3;
Employee employee[SIZE];
string EMPLOYEE;
int TYPE;
string ;VACATION
string SICK;
for (int i=0; i<SIZE;i++)
{
cout << "Enter the Employee type : " << endl;
cin>>TYPE;
employee[i].settype(TYPE);
cout << "Enter the Employees type: " << endl;
cin >> TYPE;
employee[i].setemployeetype(type);
cout << "Enter the Employees Vacation days used: " << endl;
cin>>VACATION;
employee[i].setvacationdays(VACATION);
cout << "Enter the Employees SICK: " << endl;
cin>>SICK;
employee[i].setsickdays(SICK);
}
for (int i=0;i<SIZE;i++)
employee[i].show_record();
system ("pause");
return 0;
}