首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

这个程序想要干嘛?该如何解决

2012-09-14 
这个程序想要干嘛?c++沉思录上面的?想要干嘛???C/C++ code#include cstdlib#include iostreamusing na

这个程序想要干嘛?
c++沉思录上面的?
想要干嘛???

C/C++ code
#include <cstdlib>#include <iostream>using namespace std;class Trace{      public:             Trace (){noisy=0;f=stdout;}             Trace (FILE *ff){noisy=0;f=ff;}             void print(char *s){if(noisy)fprintf(f,"%S",s);}             void on(){noisy=1;}             void off(){noisy=0;}      private:              int noisy;              FILE *f;                           };int main(int argc, char *argv[]){    Trace t(stderr);    t.print("begin main()\n");    //main函数的主体    t.print("end main()\n");     system("PAUSE");    return EXIT_SUCCESS;}


[解决办法]
日志类 可以把日志输到控制台和文件里


[解决办法]
void print(char *s){if(noisy)fprintf(f,"%s",s);}


Trace t(stderr); //控制台

Trace t(文件指针);

热点排行