Advertisement
Guest User

Untitled

a guest
Aug 15th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cstring>
  3. #include <cstdio>
  4.  
  5. using namespace std;
  6. class employee {
  7. public:
  8.   employee(char *, long, float);
  9.   ~employee();
  10.  
  11.   void show_employee();
  12.   int change_salary( float);
  13.   long get_id();
  14.  
  15. private:
  16.   char name[64];
  17.   long employee_id;
  18.   float salary;
  19. };
  20.  
  21. employee::employee(char *name, long employee_id, float salary) {
  22.   strcpy(employee::name, name);
  23.   employee::employee_id = employee_id;
  24.   if (salary < 50000.0) {
  25.    employee::salary = salary;
  26.  } else { // Недопустимый оклад
  27.    employee::salary; // в 0.0;
  28.  }
  29. }
  30. employee::~employee() {
  31.  cout << "Уничтожение объекта для " << name << endl;
  32. }
  33.  
  34. void employee::show_employee(void) {
  35.   cout << "Служащий:" << name << endl;
  36.   cout << "Номер служащего: " << employee_id << endl;
  37.   cout << "Оклад: " << salary << endl;
  38. }
  39.  
  40. int main() {
  41.  employee worker("Happy Jamsa", 101, 10101.0);
  42.  worker.show_employee();
  43.  getchar();
  44. }
  45.  
  46. // Лог ошибок.
  47. // Valentine.cpp: In constructor ‘employee::employee(char*, long int, float)’:
  48. // Valentine.cpp:25:19: warning: statement has no effect
  49. // Valentine.cpp: In function ‘int main()’:
  50. // Valentine.cpp:38:46: warning: deprecated conversion from string constant to ‘char*’
  51. // Compilation finished successfully.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement