Yahoo India Web Search

Search results

  1. Dictionary
    useful
    /ˈjuːsf(ʊ)l/

    adjective

    More definitions, origin and scrabble points

  2. Nov 27, 2015 · The most common use (by far) of #define is for include guards: // header.hh #ifndef HEADER_HH_ #define HEADER_HH_ namespace pony { // ... } #endif Another common use of #define is in creating a configuration file, commonly a config.h file, where we #define macros based on various states and conditions.

  3. What is #define useful for? Why use constants instead of variables? The answers to which are: #define can do more complicated things then just replace a number with a name. It can actually take parameters. For example: #define getmax(a,b) a>b?a:b does not merely replace a number with a name.

  4. Mar 28, 2018 · Most compilers will allow you to define a macro from the command line (e.g. g++ -DDEBUG something.cpp), but you can also just put a define in your code like so: #define DEBUG Some resources: Wikipedia article; C++ specific site; Documentation on GCC's preprocessor; Microsoft reference; C specific site (I don't think it's different from the C++ ...

  5. I can't think of a reason why people shouldn't use it, when appropriate. It is useful in some circumstances, and not in others. I think that because it's an interesting technique, some coders perhaps end up using it more often than they should, without real justification. This has given recursion a bad name in some circles.

  6. Nov 27, 2015 · In one of the answers to this question jalf spoke about useful define NOMINMAX, that could prevent from unwanted defining min/max macros. Are there other useful defines that can help to control windows.h (or other Windows headers, for instance Microsoft C Runtime headers or STL implementation) behavior?

  7. the substituted value need not be legal (or discrete) in the context where the #define is created, as it's evaluated at each point of use, so you can reference not-yet-declared objects, depend on "implementation" that needn't be pre-included, create "constants" such as { 1, 2 } that can be used to initialise arrays, or #define MICROSECONDS *1E-6 etc. (definitely not recommending this!)

  8. Sep 3, 2008 · This is useful when you want to pass around a record that has only a couple of fields, or a record that is only used in a few places. In that case specifying a whole new record type with field names (in Python, you'd use an object or a dictionary, as above) could be too verbose.

  9. Jan 17, 2011 · As for me to make the code readable in future the most useful aplyable case of enumeration is represented in next snippet: public enum Items { MESSAGES, CHATS, CITY_ONLINE, FRIENDS, PROFILE, SETTINGS, PEOPLE_SEARCH, CREATE_CHAT } @Override public boolean onCreateOptionsMenu(Menu menuPrm) { // Inflate the menu; this adds items to the action bar if it is present.

  10. There are other useful examples too: many of which include the __FILE__ and __LINE__ preprocessor macros. Anyway, macros are very useful when used correctly. Macros are not evil -- their misuse is evil.

  11. Nov 14, 2015 · For some uses of #define macros, this means #define just before a function in .cpp file, then #undef right after the function. The exact use case for #define determines if it should be in .h or in .cpp file. But note that most use cases are actually in violation of 3. above, and you should actually not use #define.