Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
terralib:convencaoprograma [2008/04/02 11:39]
laercio
terralib:convencaoprograma [2008/04/02 16:22] (current)
laercio
Line 24: Line 24:
   * Use macros sparingly   * Use macros sparingly
   * Do not use "#​define"​ to define constants – declare static const variables instead   * Do not use "#​define"​ to define constants – declare static const variables instead
 +
 ===== Example ===== ===== Example =====
 <code cpp> <code cpp>
Line 31: Line 32:
 static const float TeMaxFloat = 3.4e37; static const float TeMaxFloat = 3.4e37;
 .... ....
-#endif //end TE_CONNECTION_POOL_H+#endif // end TE_CONNECTION_POOL_H
 </​code>​ </​code>​
 +
  
  
Line 40: Line 42:
   * Do not define enumerations using macros or integer constants   * Do not define enumerations using macros or integer constants
   * Declare enumerations within a namespace or class   * Declare enumerations within a namespace or class
 +
 +===== Example =====
 +<code cpp>
 +typedef std::​pair<​TeLine,​ double> TeLineLength;​
 +typedef std::​vector<​lineLength>​ TeLineSizes;​
 +
 +enum TeSelectionMode
 +{
 +  TeSelectionModeDefault,​  ​ //!< default selection
 +  TeSelectionModeTePointed,​  ​ //!< object pointed
 +  TeSelectionModeTeQueried,​  ​ //!< object queried
 +  TeSelectionModeTePointedQueried //!< object pointed and queried
 +}
 +</​code>​
 +
  
 ====== Escopo ====== ====== Escopo ======
   * Declare for-loop iteration variables inside of for statements   * Declare for-loop iteration variables inside of for statements
 +===== Example ===== 
 +<code cpp> 
 +for (int i = 0; i < 10; i++) 
 +</​code>​
  
  
Line 110: Line 130:
 } }
 </​code>​ </​code>​
 +
  
  
Line 116: Line 137:
  
   * Use C++ casting operators instead of C-style casts. Ex:<code cpp>   * Use C++ casting operators instead of C-style casts. Ex:<code cpp>
-short a=2000;+short a = 2000;
 int b; int b;
 b = (int) a;    // c-like cast notation - Ok only for fundamental data types b = (int) a;    // c-like cast notation - Ok only for fundamental data types
  
-double d=3.14159265;​+double d = 3.14159265;
 int i = static_cast<​int>​(d);​ // No need for this cast int i = static_cast<​int>​(d);​ // No need for this cast
 </​code>​ </​code>​

Navigation