class
I want to write a class which keep to employee's informations.But I made a mistake somewhere but I didn't understand.Please,help me.Thank you.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
employee.h
#ifndef ABC
#define ABC
char m_strname[25];
int m_nTC;
double m_dsalary;
#endif
employee.cpp
#include"employee.h"
// Set the employee information
void SetInfo(char *strname, int nTC, double dsalary)
{
strncpy(m_strname, strname, 25);
m_nTC = nTC;
m_dsalary = dsalary;
}
// Print employee information to the screen
void Print()
{
using namespace std;
cout << "Name: " << m_strname << " TC: " << m_nTC << " Salary: $" << m_dsalary << endl;
}
test.cpp
#include<iostream>
#include"employee.h"
#include"employee.cpp"
using namespace std;
int main()
{
// Declare three employees
Employee cAli;
cAli.SetInfo("Ali",11454,1543.65);
Employee cAhmet;
cAhmet.SetInfo("Ahmet",13246,1956.34 );
Employee cMehmet;
cMehmet.SetInfo("Mehmet",21379,2178.91);
// Print out the employee information
cAli.Print();
cAhmet.Print();
cMehmet.Print();
return 0;
}
|
What is the definition of "Employee"?
Topic archived. No new replies allowed.