Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // example opening file for appending
- // Ohm Shah
- // 03/14/2019
- #include <fstream>
- #include <iostream>
- #include <string>
- class Logger{
- public:
- static Logger *instance;
- static Logger *getInstance(){
- if(instance == nullptr)
- instance = new Logger;
- return instance;
- }
- void report(const std::string&);
- private:
- };
- void Logger::report(const std::string& addMe){
- std::ofstream fout;
- fout.open("log.txt", std::fstream::out | std::fstream::app);
- fout << "more lorem ipsum" << std::endl;
- fout << addMe;
- fout.close();
- }
- int main () {
- const std::string addMe = "ADDD THIS STUFF";
- Logger::getInstance()->report(addMe);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement