fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. #include<iostream>
  5. #include<fstream>
  6. #include<string>
  7. using namespace std;
  8. class employee
  9. {
  10. private:
  11. int emplno;
  12. char name[20];
  13. char department[20];
  14. double salary;
  15. char managername[20];
  16. public:
  17. void getEmployeeInfo()
  18. {
  19. cout << "Enter employee number:";
  20. cin >> emplno;
  21. cout << "Enter name:";
  22. cin >> name;
  23. cout << "Enter department:";
  24. cin >> department;
  25. cout << "Enter salary:";
  26. cin >> salary;
  27. cout << "Enter manager name:";
  28. cin >> managername;
  29. }
  30. void writeEmployee(fstream &file)
  31. {
  32. char terminator[1];
  33. terminator[0] = '\n';
  34. file.write(char(emplno));
  35. file.write(name, sizeof(name));
  36. file.write(department, sizeof(department));
  37. file.write(char(int(salary)));
  38. file.write(managername, sizeof(managername));
  39. file.write(terminator, sizeof(terminator));
  40.  
  41. }
  42.  
  43. };
  44.  
  45. int main() {
  46. // your code goes here
  47. return 0;
  48. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In member function ‘void employee::writeEmployee(std::fstream&)’:
prog.cpp:34:27: error: no matching function for call to ‘std::basic_fstream<char>::write(char)’
    file.write(char(emplno));
                           ^
In file included from /usr/include/c++/6/ostream:638:0,
                 from /usr/include/c++/6/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/6/bits/ostream.tcc:182:5: note: candidate: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::write(const _CharT*, std::streamsize) [with _CharT = char; _Traits = std::char_traits<char>; std::streamsize = long int]
     basic_ostream<_CharT, _Traits>::
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/bits/ostream.tcc:182:5: note:   candidate expects 2 arguments, 1 provided
prog.cpp:37:32: error: no matching function for call to ‘std::basic_fstream<char>::write(char)’
    file.write(char(int(salary)));
                                ^
In file included from /usr/include/c++/6/ostream:638:0,
                 from /usr/include/c++/6/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/6/bits/ostream.tcc:182:5: note: candidate: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::write(const _CharT*, std::streamsize) [with _CharT = char; _Traits = std::char_traits<char>; std::streamsize = long int]
     basic_ostream<_CharT, _Traits>::
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/bits/ostream.tcc:182:5: note:   candidate expects 2 arguments, 1 provided
stdout
Standard output is empty