C++ 打印输出日志文件

1、Log.h


#pragma once


#include
#include
using namespace std;


class CLog
{
public:
CLog(void);
~CLog(void);
void AddContent(string strMsg);
};


2、Log.cpp

#include "StdAfx.h"
#include "Log.h"


CLog::CLog(void)
{
}


CLog::~CLog(void)
{
}


void CLog::AddContent(string strMsg)
{
ofstream outfile;
outfile.open("Log.txt",ios_base::app | ios_base::out); //存放数据的文件名  
    if(outfile.is_open())
    {
outfile<         outfile.close();
    }
    else
    {
       cout<<"不能打开文件!"<     }
}

你可能感兴趣的:(c++)