c++ Programming Glossary: prefer
#pragma once vs include guards? http://stackoverflow.com/questions/1143936/pragma-once-vs-include-guards declare instead of including in .h files when you can. I prefer to use #pragma once . See this wikipedia article about the possibility..
Storing C++ template function definitions in a .CPP file http://stackoverflow.com/questions/115703/storing-c-template-function-definitions-in-a-cpp-file in a .CPP file I have some template code that I would prefer to have stored in a CPP file instead of inline in the header...
Visual Studio support for new C / C++ standards? http://stackoverflow.com/questions/146381/visual-studio-support-for-new-c-c-standards we get from the majority of our users is that they would prefer that we focus on C 0x instead of on C 99. We have cherry picked..
Is there a simple script to convert C++ enum to string? http://stackoverflow.com/questions/201593/is-there-a-simple-script-to-convert-c-enum-to-string f0 name my_enum.h GCC_XML You could use any language you prefer to pull out the Enumeration and EnumValue tags and generate..
Get the IP address of the machine http://stackoverflow.com/questions/212528/get-the-ip-address-of-the-machine and actually that's what I do at the moment . I would prefer to detect the public address though. c linux networking ip..
C++: “std::endl” vs “\n” http://stackoverflow.com/questions/213907/c-stdendl-vs-n std cout Test line n Is there a technical reason to prefer one over the other or is it just a matter of coding style c..
How to write a browser plugin? http://stackoverflow.com/questions/2649056/how-to-write-a-browser-plugin Opera. I'm thinking specifically of Windows here and would prefer working with C . Are there any tools or tutorials that detail..
Regular cast vs. static_cast vs. dynamic_cast http://stackoverflow.com/questions/28002/regular-cast-vs-static-cast-vs-dynamic-cast would give you a compile time error for that. Some people prefer c style casts because of their brevity. I use them for numeric..
C++ cast syntax styles http://stackoverflow.com/questions/32168/c-cast-syntax-styles static_cast vs. dynamic_cast What cast syntax style do you prefer in C C style cast syntax int foo C style cast syntax static_cast..
Operator overloading http://stackoverflow.com/questions/4421706/operator-overloading the prefix variant. This is a good reason to generally prefer prefix increment over postfix increment. While compilers can.. a b is in general more efficient than a b and should be preferred if possible. Array Subscription The array subscription operator..
What does T&& (double ampersand) mean in C++11? http://stackoverflow.com/questions/5481539/what-does-t-double-ampersand-mean-in-c11 reference properties For overload resolution lvalues prefer binding to lvalue references and rvalues prefer binding to rvalue.. lvalues prefer binding to lvalue references and rvalues prefer binding to rvalue references . Hence why temporaries prefer.. binding to rvalue references . Hence why temporaries prefer invoking a move constructor move assignment operator over a..
How to build Qt for Visual Studio 2010 http://stackoverflow.com/questions/5601950/how-to-build-qt-for-visual-studio-2010 doesn't matter if it's in system path or user path If you prefer to use Control Panel System Environment Variables then you can..
Compilers and argument order of evaluation in C++ http://stackoverflow.com/questions/621542/compilers-and-argument-order-of-evaluation-in-c a platform one. The language standard does not gurantee or prefer one over the other and leaves it as unspecified . Note the wording...
Object destruction in C++ http://stackoverflow.com/questions/6403055/object-destruction-in-c and the exception is propagated. You should generally prefer std vector Foo over Foo for dynamic arrays. It makes writing.. in sharing that dynamic object. You should generally prefer std shared_ptr Foo over Foo for shared objects. It makes writing..
C++: When to use References vs. Pointers http://stackoverflow.com/questions/7058339/c-when-to-use-references-vs-pointers needs a reference argument but in general I'm finding I prefer to use pointers and const pointers as the syntax is clear that.. with raw arrays it seems the choice comes down to personal preference. I've accepted the answer below that references Google's..
Why does the use of 'new' cause memory leaks? http://stackoverflow.com/questions/8839943/why-does-the-use-of-new-cause-memory-leaks delete it even if you wanted What you should do You should prefer automatic storage duration. Need a new object just write A a..
Why should I prefer to use member initialization list? http://stackoverflow.com/questions/926752/why-should-i-prefer-to-use-member-initialization-list should I prefer to use member initialization list I'm partial to using member..
Class design vs. IDE: Are nonmember nonfriend functions really worth it? http://stackoverflow.com/questions/135634/class-design-vs-ide-are-nonmember-nonfriend-functions-really-worth-it otherwise excellent book C Coding Standards Item 44 titled Prefer writing nonmember nonfriend functions Sutter and Alexandrescu..
Namespace + functions versus static methods on a class http://stackoverflow.com/questions/1434937/namespace-functions-versus-static-methods-on-a-class wrote a whole Item for his Effective C book on this topic Prefer non member non friend functions to member functions . I found..
When should functions be member functions? http://stackoverflow.com/questions/1638394/when-should-functions-be-member-functions form in the 3rd edition of Meyer's Effective C Item 23 Prefer non member non friend functions to member functions and Sutter.. functions and Sutter Alexandrescu's C Coding Standards 44 Prefer writing nonmember nonfriend functions . I think a lot of developers..
Pass by reference more expensive than pass by value http://stackoverflow.com/questions/2108084/pass-by-reference-more-expensive-than-pass-by-value by reference pass by value share improve this question Prefer passing primitive types int char float ... and POD structs that..
Private virtual method in C++ http://stackoverflow.com/questions/2170688/private-virtual-method-in-c Sutter has very nicely explained it here . Guideline #2 Prefer to make virtual functions private. This lets the derived classes..
C++ Error Handling — Good Sources of Example Code? http://stackoverflow.com/questions/231128/c-error-handling-good-sources-of-example-code errors and non errors Design and write error safe code Prefer to use exceptions to report errors Throw by value catch by reference..
Most crucial elements in a light-weight C++ coding standard [closed] http://stackoverflow.com/questions/242728/most-crucial-elements-in-a-light-weight-c-coding-standard c coding style share improve this question Prefer RAII . STL's auto and shared in boost C 0x pointers may help...
How to read a value from the Windows registry http://stackoverflow.com/questions/34065/how-to-read-a-value-from-the-windows-registry the speed of light if I write to the registry incorrectly. Prefer answers in C but mostly just need to know what the special Windows..
C++ class header files organization http://stackoverflow.com/questions/346058/c-class-header-files-organization per file. It depends on the structure of your code. Prefer forward declaration over #include s whenever possible. This..
What techniques can be used to speed up C++ compilation times? http://stackoverflow.com/questions/373142/what-techniques-can-be-used-to-speed-up-c-compilation-times headers don't have a respective declarations header. Prefer pass by reference to pass by value in function signatures. This..
C++ - enum vs. const vs. #define http://stackoverflow.com/questions/4767667/c-enum-vs-const-vs-define yourself here http www.ideone.com naZ3P Also read Item 2 Prefer consts enums and inlines to #defines from Effective C by Scott..
Effective C++ Item 23 Prefer non-member non-friend functions to member functions http://stackoverflow.com/questions/5989734/effective-c-item-23-prefer-non-member-non-friend-functions-to-member-functions C Item 23 Prefer non member non friend functions to member functions While puzzling.. or not I looked into Effective c and found Item 23 namely Prefer non member non friend functions to member functions. Reading..
Why should one not derive from c++ std string class? http://stackoverflow.com/questions/6006860/why-should-one-not-derive-from-c-std-string-class For more information see Scott Meyers' Effective C Item 23 Prefer non member non friend functions to member functions. EDIT Here's..
Should I prefer iterators over const_iterators? http://stackoverflow.com/questions/765257/should-i-prefer-iterators-over-const-iterators brought up the article from Scott Meyers that says Prefer iterators over const_iterators pdf link . Someone else was commenting..
Circular Dependencies / Incomplete Types http://stackoverflow.com/questions/7666665/circular-dependencies-incomplete-types I follow Don't include an include from an include dude. Prefer forward declarations if possible. Exception include system includes..
Which kind of pointer do I use when? http://stackoverflow.com/questions/8706192/which-kind-of-pointer-do-i-use-when algorithm to determine when to use which smart pointer Preferably including advice regarding dumb pointers raw pointers like.. the resource will outlive the referencing object scope. Prefer references and use raw pointers when you need either nullability..
|