Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. // example opening file for appending
  2. // Ohm Shah
  3. // 03/14/2019
  4.  
  5. #include <fstream>
  6. #include <iostream>
  7. #include <string>
  8.  
  9. class Logger{
  10. public:
  11. static Logger *instance;
  12. static Logger *getInstance(){
  13. if(instance == nullptr)
  14. instance = new Logger;
  15. return instance;
  16. }
  17. void report(const std::string&);
  18.  
  19. private:
  20. };
  21.  
  22. void Logger::report(const std::string& addMe){
  23. std::ofstream fout;
  24. fout.open("log.txt", std::fstream::out | std::fstream::app);
  25. fout << "more lorem ipsum" << std::endl;
  26. fout << addMe;
  27. fout.close();
  28. }
  29.  
  30. int main () {
  31. const std::string addMe = "ADDD THIS STUFF";
  32. Logger::getInstance()->report(addMe);
  33.  
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement