This should be a common problem and possibly similar to some question here but i am looking foe the best way to comment out multiple lines (rather methods ) in C++ which hav
The stuff between the #if 0
and #endif
will be ignored by the compiler. (Your preprocessor might actually strip it out before the "compiler" can even take a look at it!)
#if 0
/* 42 is the answer. */
Have you tried jQuery?
@Compiler Stop ignoring me!!
#endif
You'll have better control if you use #ifdef
s:
// #define DEBUG
#ifdef DEBUG
MyFunction();
std::cout << "DEBUG is defined!";
#endif
// Later in your code...
#ifdef DEBUG
std::cout << "DEBUG is still defined!";
#endif
Just uncomment the first line, and your #ifdef DEBUG
code will suddenly be visible to the compiler.
P.S. This should clear any more confusion:
/*
cout << "a";
/*
cout << "b";
*/
cout << "c";
*/
The output should be "c"
, assuming your compiler doesn't give you any errors for the last */
.