Average article rating: 4.91
Programming Languages
|
Visual C++ 10.0 |
13 Aug 2014
Updated: 13 Aug 2014
Rating: 4.91/5
Votes: 12
Popularity: 5.11
Licence: CPOL
Views: 24,738
Bookmarked: 11
Downloaded: 0
How to avoid overflow and still retain precision on large integer calculations
|
Average blogs rating:
No blogs have been submitted.
Average tips rating: 4.54
C |
2 Mar 2010
Updated: 2 Mar 2010
Rating: 4.67/5
Votes: 5
Popularity: 3.26
Licence: CPOL
Views: 12,170
Bookmarked: 2
Downloaded: 0
Header files often #include lots of other headers because other classes are being referenced. These chained includes force the compiler to repeatedly load and precompile long lists of headers over and over again. Thanks to #pragma directives or #ifdef guards this is a rather cheap operation,...
|
|
2 Mar 2010
Updated: 2 Mar 2010
Rating: 4.27/5
Votes: 4
Popularity: 2.57
Licence: CPOL
Views: 10,400
Bookmarked: 2
Downloaded: 0
When you compare a variable (a lvalue) to a constant (not a lvalue), always write the lvalue on the right hand side of the comparison.Bad example:if ( n == 5 ){ // do something}Good example:if ( 5 == n ){ // do something}This will help with your debugging in case...
|
C# |
2 Mar 2010
Updated: 2 Mar 2010
Rating: 4.56/5
Votes: 2
Popularity: 1.37
Licence: CPOL
Views: 6,330
Bookmarked: 0
Downloaded: 0
I actually prefer initialization over assignment, like this:private void Method(){ int Var2; int Var3; // some more statements int Var1(10);}In doing this you prevent later edits to again separate the declaration from the assignment by inserting code between them.
|
C++ |
2 Mar 2010
Updated: 2 Mar 2010
Rating: 4.40/5
Votes: 3
Popularity: 2.10
Licence: CPOL
Views: 18,861
Bookmarked: 1
Downloaded: 0
When incrementing or decrementing a variable, favor prefix operators over postfix operators if you do not need the value of the expression.Example:void foo(std::vector intvec){ for (std::vector::iterator it = intvec.begin(); it != intvec.end(); ++it) { // do something ...
|
|
7 Feb 2012
Updated: 7 Feb 2012
Rating: 4.56/5
Votes: 2
Popularity: 1.37
Licence: CPOL
Views: 7,930
Bookmarked: 0
Downloaded: 0
If you're using templates already, and are willing to adapt your class definitions, then this should work:template class BaseClass {public: virtual bool equals(T* other) = 0;};template class ChildClass : public BaseClass > {public: typedef...
|
C++11 |
24 Jan 2012
Updated: 24 Jan 2012
Rating: 4.76/5
Votes: 7
Popularity: 4.03
Licence: CPOL
Views: 15,291
Bookmarked: 0
Downloaded: 0
Consider the following scenario:Your team provides libraries for use in other, unspecified applications. When designing your API, you have to consider the fact that not every customer will have access to the newest compiler.Let's say you develop a Vector class that looks like...
|
Average reference rating:
No reference articles have been posted.
Average project rating:
No projects have been posted.
Software Developer (Senior)
Switzerland
Graduated at TU Darmstadt in Math & CS, with a heavy focus on CAD/CAM
Programming and designing applications in C++ in the areas AI, real-time programming, client-server applications and CAD/CAM since 1985.
Personal interests: AI, computer graphics, games, reading