C ++ Shen Shuographic (prelude) study notes

zhaozj2021-02-12  184

The authors use a TRACE class to comparison with some advantages and disadvantages of C and C language, why is C instead of C?

#include 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;}

#include static int noisy = 1; void trace (noisy) PRINTF ("% s / n", s);} void trace_on () {noisy = 1;} void trace_off () {noisy = 0;}

C uses classes to tie the properties and movements of things together, provide a place to describe the property (explicitly available), indicating the interrelationship of things, making us better indicating our intentions.

So we use C .

转载请注明原文地址:https://www.9cbs.com/read-6468.html

New Post(0)