<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://www.programmingexamples.net/w/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.programmingexamples.net/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mikael.s.persson</id>
		<title>ProgrammingExamples - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://www.programmingexamples.net/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mikael.s.persson"/>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/Special:Contributions/Mikael.s.persson"/>
		<updated>2026-06-14T07:47:59Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.23.5</generator>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP/Boost/BGL/d_ary_heap_indirect</id>
		<title>CPP/Boost/BGL/d ary heap indirect</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP/Boost/BGL/d_ary_heap_indirect"/>
				<updated>2012-01-25T22:58:26Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: /* d_ary_heap_indirect.cpp */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==d_ary_heap_indirect.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;iomanip&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
#include &amp;lt;boost/graph/grid_graph.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/graph/detail/d_ary_heap.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/property_map/property_map.hpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;cstdlib&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
template &amp;lt;typename T&amp;gt;&lt;br /&gt;
struct LessThanFunctor&lt;br /&gt;
{&lt;br /&gt;
  bool operator()(const T&amp;amp; a, const T&amp;amp; b)&lt;br /&gt;
  {&lt;br /&gt;
    return a &amp;lt; b;&lt;br /&gt;
  }&lt;br /&gt;
};&lt;br /&gt;
 &lt;br /&gt;
int main(int argc, char*argv[])&lt;br /&gt;
{&lt;br /&gt;
  srand((unsigned int)time(NULL));&lt;br /&gt;
&lt;br /&gt;
  boost::array&amp;lt;std::size_t, 2&amp;gt; lengths = { { 5,5 } };&lt;br /&gt;
  typedef boost::grid_graph&amp;lt;2&amp;gt; GraphType;&lt;br /&gt;
  GraphType graph(lengths);&lt;br /&gt;
  typedef boost::graph_traits&amp;lt;GraphType&amp;gt;::vertex_descriptor Vertex;&lt;br /&gt;
  typedef boost::property_map&amp;lt;GraphType, boost::vertex_index_t&amp;gt;::const_type GridIndexMapType;&lt;br /&gt;
  GridIndexMapType gridIndexMap(get(boost::vertex_index, graph));&lt;br /&gt;
 &lt;br /&gt;
  typedef boost::vector_property_map&amp;lt;std::size_t, GridIndexMapType&amp;gt; IndexInHeapMap;&lt;br /&gt;
  IndexInHeapMap index_in_heap(gridIndexMap);&lt;br /&gt;
  &lt;br /&gt;
  boost::graph_traits&amp;lt;GraphType&amp;gt;::vertex_iterator ui, ui_end;&lt;br /&gt;
  for( tie(ui,ui_end) = vertices(graph); ui != ui_end; ++ui)&lt;br /&gt;
    put(index_in_heap, *ui, static_cast&amp;lt;std::size_t&amp;gt;(-1));&lt;br /&gt;
  &lt;br /&gt;
  typedef boost::vector_property_map&amp;lt;float, GridIndexMapType&amp;gt; PriorityMapType;&lt;br /&gt;
  PriorityMapType priorityMap(gridIndexMap);&lt;br /&gt;
  for( tie(ui,ui_end) = vertices(graph); ui != ui_end; ++ui)&lt;br /&gt;
    put(priorityMap, *ui, rand() % 1000);&lt;br /&gt;
  &lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;Given the following random grid-graph: &amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  Vertex v = vertex(0,graph);&lt;br /&gt;
  for(std::size_t i = 0; i &amp;lt; lengths[0]; ++i) {&lt;br /&gt;
    Vertex u = v;&lt;br /&gt;
    for(std::size_t j = 0; j &amp;lt; lengths[1]; ++j) {&lt;br /&gt;
      std::cout &amp;lt;&amp;lt; std::setw(5) &amp;lt;&amp;lt; get(priorityMap, u);&lt;br /&gt;
      u = graph.next(u,1);&lt;br /&gt;
    };&lt;br /&gt;
    v = graph.next(v,0);&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  };&lt;br /&gt;
  &lt;br /&gt;
  typedef boost::d_ary_heap_indirect&amp;lt;Vertex, 4, IndexInHeapMap, PriorityMapType, LessThanFunctor&amp;lt;float&amp;gt; &amp;gt; MutableQueue;&lt;br /&gt;
 &lt;br /&gt;
  LessThanFunctor&amp;lt;float&amp;gt; lessThanFunctor;&lt;br /&gt;
  MutableQueue mutableQueue(priorityMap, index_in_heap, lessThanFunctor);&lt;br /&gt;
&lt;br /&gt;
  for( tie(ui,ui_end) = vertices(graph); ui != ui_end; ++ui)&lt;br /&gt;
    mutableQueue.push(*ui); &lt;br /&gt;
  &lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;We get the following priority queue: &amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  while( ! mutableQueue.empty() ) {&lt;br /&gt;
    Vertex u = mutableQueue.top(); mutableQueue.pop();&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; std::setw(5) &amp;lt;&amp;lt; get(priorityMap, u);&lt;br /&gt;
  };&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==CMakeLists.txt==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
cmake_minimum_required(VERSION 2.6)&lt;br /&gt;
&lt;br /&gt;
Project(d_ary_heap_indirect)&lt;br /&gt;
&lt;br /&gt;
set(Boost_USE_MULTITHREADED ON)&lt;br /&gt;
FIND_PACKAGE(Boost 1.38 COMPONENTS)&lt;br /&gt;
&lt;br /&gt;
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${Boost_INCLUDE_DIRS})&lt;br /&gt;
LINK_DIRECTORIES(${LINK_DIRECTORIES} ${Boost_LIBRARY_DIRS})&lt;br /&gt;
&lt;br /&gt;
ADD_EXECUTABLE(d_ary_heap_indirect d_ary_heap_indirect.cpp)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP/C%2B%2B0x/TheBigFive</id>
		<title>CPP/C++0x/TheBigFive</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP/C%2B%2B0x/TheBigFive"/>
				<updated>2011-07-21T13:55:05Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: The Big Five&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In C++0x, whenever writing a resource-holding class, where it is required to perform deep copies, it usually also makes sense to provide move-semantics via a move constructor and a swap function. This can be called the Rule of Five (or The Big Five), that is, you should provide a copy-constructor, a move-constructor, a swap function, a copy-assignment (via copy-and-swap or move-and-swap), and a destructor to free the resources. Below is an example of a simple vector class which holds a dynamic array, and thus, is required to provide the Big Five.&lt;br /&gt;
&lt;br /&gt;
The copy-constructor is implemented as in C++03/98, performing a deep-copy by allocating a new dynamic array and copying the data from the source object. Note that this constructor can also benefit from delegating constructors in C++0x, although not yet supported on most compilers (21/07/2011).&lt;br /&gt;
&lt;br /&gt;
The move-constructor is responsible for two things: &amp;quot;stealing&amp;quot; the resource from the source object and nullifying the resources that the source object holds. This is important. Move-semantics enable two things, it allows one to move the resources from one object to another and it allows perfect forwarding of temporary variables. Since the object to which the rvalue-reference refers to will eventually get destructed, it is important that its resources be nullified such that its destructor has no effect (and does not free the resources that are now held by the new object). As shown below, a move-constructor typically looks like a shallow copy of the data members, followed by setting the source object to a &amp;quot;zombie-state&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Then, another very important function to implement for resource-holding classes is the swap() function. This function swaps the content of two object. This is implemented as it is usual in C++03/98. As shown below, parameters are taken as non-const references (not rvalue-ref) because it only makes sense to swap lvalued objects. Second, the first line of any swap() function is usually the &amp;quot;using std::swap;&amp;quot; statement which allows the ADL (Argument Dependent Lookup) to consider the standard swap function, from the &amp;lt;algorithm&amp;gt; header. All data members of the class should have either a custom swap() function in their own namespace or be satisfied with being swapped by the standard function, and thus, ADL will select the appropriate overloaded swap function (provided that the std::swap name is imported). This also justifies the presence of a swap function, as a friend function, because whenever there is a better way to swap to objects than using the standard function (which performs three deep-copies), then it is justified to have a swap friend function.&lt;br /&gt;
&lt;br /&gt;
Now, with a swap function, the assignment operator can be implemented via the standard copy-and-swap idiom. However, now, the assignment operator can serve a double purpose, as a copy-assignment and as a move-assignment. The standard copy-and-swap idiom passes the object by value, as opposed to the usual const-reference, because this will use the copy-constructor to actually create the copy (i.e. the deep-copy implementation only needs to exist in the copy-constructor), and then swaps the &amp;quot;this&amp;quot; object with the copy. This process leaves the temporary parameter with the original resources of the &amp;quot;this&amp;quot; object and the &amp;quot;this&amp;quot; object with a deep-copy of the source object. This implementation is simple, efficient, minimizes code duplication, and provides strong exception safety (as only the copy-constructor can fail, not the swap, if an exception occurs, the assignment will never be performed and the &amp;quot;this&amp;quot; object will safely keep its original state). When moving towards C++0x and move-semantics, no extra effort is required to implement a &amp;quot;move-and-swap&amp;quot; because, by passing by value to the assignment, the move-constructor will be selected to construct the parameter if that is the most sensible option given the calling context (either explicitly using std::move() or if assigned to a temporary rvalue).&lt;br /&gt;
&lt;br /&gt;
Finally, a destructor is needed which will release the resources correctly, unless RAII is used for all data members, of course.&lt;br /&gt;
&lt;br /&gt;
==TheBigFive.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;algorithm&amp;gt;&lt;br /&gt;
&lt;br /&gt;
class my_vector {&lt;br /&gt;
  private:&lt;br /&gt;
    int* ptr;&lt;br /&gt;
    unsigned int sz;&lt;br /&gt;
  public:&lt;br /&gt;
&lt;br /&gt;
    int&amp;amp; operator[](unsigned int i) { return ptr[i]; };&lt;br /&gt;
    const int&amp;amp; operator[](unsigned int i) const { return ptr[i]; };&lt;br /&gt;
    unsigned int size() const { return sz; };&lt;br /&gt;
    &lt;br /&gt;
    my_vector(unsigned int aSize = 0) : &lt;br /&gt;
              ptr((aSize ? new int[aSize] : nullptr)), &lt;br /&gt;
              sz(aSize) { };&lt;br /&gt;
&lt;br /&gt;
    // 1 - Copy-Constructor&lt;br /&gt;
    my_vector(const my_vector&amp;amp; rhs) : &lt;br /&gt;
              ptr((rhs.sz ? new int[rhs.sz] : nullptr)), &lt;br /&gt;
              sz(rhs.sz) { &lt;br /&gt;
      std::copy(rhs.ptr, rhs.ptr + rhs.sz, ptr); &lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
/*  1 - Copy-Constructor using delegating constructors (not yet supported by GCC)&lt;br /&gt;
    my_vector(const my_vector&amp;amp; rhs) : my_vector(rhs.sz) {&lt;br /&gt;
      std::copy(rhs.ptr, rhs.ptr + rhs.sz, ptr);&lt;br /&gt;
    };&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
    // 2 - Move-Constructor&lt;br /&gt;
    my_vector(my_vector&amp;amp;&amp;amp; rhs) : &lt;br /&gt;
              ptr(rhs.ptr), &lt;br /&gt;
              sz(rhs.sz) { &lt;br /&gt;
      rhs.ptr = nullptr; &lt;br /&gt;
      rhs.sz = 0; &lt;br /&gt;
    };&lt;br /&gt;
    &lt;br /&gt;
    // 3 - Swap function&lt;br /&gt;
    friend void swap(my_vector&amp;amp; lhs, my_vector&amp;amp; rhs) throw() {&lt;br /&gt;
      using std::swap;&lt;br /&gt;
      swap(lhs.ptr,rhs.ptr);&lt;br /&gt;
      swap(lhs.sz,rhs.sz);&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    // 4 - Copy-assignment operator&lt;br /&gt;
    my_vector&amp;amp; operator=(my_vector rhs) {&lt;br /&gt;
      swap(*this,rhs);&lt;br /&gt;
      return *this;&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    // 5 - Destructor&lt;br /&gt;
    ~my_vector() {&lt;br /&gt;
      delete[] ptr;&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
  my_vector v(3);&lt;br /&gt;
  v[0] = 0; v[1] = 1; v[2] = 2;&lt;br /&gt;
&lt;br /&gt;
  my_vector v1(v); //copy-constructor.&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;v.size  = &amp;quot; &amp;lt;&amp;lt; v.size() &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;v1.size = &amp;quot; &amp;lt;&amp;lt; v1.size() &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
&lt;br /&gt;
  my_vector v2(std::move(v)); //move-constructor&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;v.size  = &amp;quot; &amp;lt;&amp;lt; v.size() &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;v2.size = &amp;quot; &amp;lt;&amp;lt; v2.size() &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
&lt;br /&gt;
  v1 = v; //copy-assignment. (copy-and-swap)&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;v1.size = &amp;quot; &amp;lt;&amp;lt; v1.size() &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
&lt;br /&gt;
  v = std::move(v2); //move-assignment. (move-and-swap)&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;v.size  = &amp;quot; &amp;lt;&amp;lt; v.size() &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;v2.size = &amp;quot; &amp;lt;&amp;lt; v2.size() &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
&lt;br /&gt;
  v2 = my_vector(4); //move-assignment, since RHS is an rvalue.&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;v2.size = &amp;quot; &amp;lt;&amp;lt; v2.size() &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==CMakeLists.txt==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
cmake_minimum_required(VERSION 2.6)&lt;br /&gt;
&lt;br /&gt;
PROJECT(TheBigFive)&lt;br /&gt;
&lt;br /&gt;
ADD_EXECUTABLE(TheBigFive TheBigFive.cpp )&lt;br /&gt;
&lt;br /&gt;
SET(CMAKE_CXX_FLAGS &amp;quot;${CMAKE_CXX_FLAGS} -Wall -std=c++0x&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP</id>
		<title>CPP</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP"/>
				<updated>2011-07-21T13:05:51Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: /* C++0x */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= C++ =&lt;br /&gt;
A statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as a &amp;quot;middle-level&amp;quot; language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell Labs as an enhancement to the C programming language and originally named C with Classes. It was renamed C++ in 1983. (http://en.wikipedia.org/wiki/C++)&lt;br /&gt;
----&lt;br /&gt;
=== Formatting ===&lt;br /&gt;
* [[CPP/Formatting/Decimals|Number of decimals (fixed and setprecision)]]&lt;br /&gt;
&lt;br /&gt;
=== General Examples ===&lt;br /&gt;
* [[CPP/StaticFunction|Static function]]&lt;br /&gt;
* [[CPP/recursion|Recursion - a recursive function]]&lt;br /&gt;
* [[CPP/unique_ptr|unique_ptr]]&lt;br /&gt;
* [[CPP/Functor|Functor]]&lt;br /&gt;
* [[CPP/ReturnByReference|Return a value by reference]]&lt;br /&gt;
* [[CPP/IntToHex|Convert an int to hex]]&lt;br /&gt;
* [[CPP/HexToInt|Convert a hex number to an int]]&lt;br /&gt;
* [[CPP/AnonymousNamespace|Anonymous namespace]]&lt;br /&gt;
* [[CPP/2DVector|2D Vector]]&lt;br /&gt;
* [[CPP/AlphebetizeString|Alphabetize a vector of strings]]&lt;br /&gt;
* [[CPP/ZeroPad|Pad a number with zeros]]&lt;br /&gt;
* [[CPP/BinaryIO|Binary input and output]]&lt;br /&gt;
* [[CPP/ExecuteLinuxCommand|Execute a linux command]]&lt;br /&gt;
* [[CPP/Casting|Casting]]&lt;br /&gt;
* [[CPP/KeyboardInput|Keyboard input]]&lt;br /&gt;
* [[CPP/CommandLineArguments|Command line arguments]]&lt;br /&gt;
* [[CPP/DeepCopy|Deep copy]]&lt;br /&gt;
* [[CPP/DefaultArguments|Default arguments]]&lt;br /&gt;
* [[CPP/Enum|Enum]]&lt;br /&gt;
* [[CPP/Exceptions|Exceptions (try/catch)]]&lt;br /&gt;
* [[CPP/Infinity|Infinity]]&lt;br /&gt;
* [[CPP/Logging|Logging]]&lt;br /&gt;
* [[CPP/Namespaces|Namespaces]]&lt;br /&gt;
* [[CPP/NAN|NAN (not a number)]]&lt;br /&gt;
* [[CPP/OverloadOperator|Overload operator]]&lt;br /&gt;
* [[CPP/ParallelSort|Parallel sort]]&lt;br /&gt;
* [[CPP/RandomNumbers|Random numbers]]&lt;br /&gt;
* [[CPP/StringStream|StringStream]]&lt;br /&gt;
* [[CPP/Struct|Struct]]&lt;br /&gt;
* [[CPP/Switch|Switch]]&lt;br /&gt;
* [[CPP/Typedef|Typedef]]&lt;br /&gt;
* [[CPP/KeepSortedList|Keeping a Sorted List of Custom Records]]&lt;br /&gt;
&lt;br /&gt;
=== I/O ===&lt;br /&gt;
* [[CPP/IO/Setw|Column width (setw)]]&lt;br /&gt;
* [[CPP/IO/FileInput|File input]]&lt;br /&gt;
* [[CPP/IO/FileOutput|File output]]&lt;br /&gt;
* [[CPP/IO/ReadingLines|Reading lines from a text file]]&lt;br /&gt;
&lt;br /&gt;
=== Strings ===&lt;br /&gt;
* [[CPP/Strings/Compare|Compare strings]]&lt;br /&gt;
* [[CPP/Strings/Concatenate|Concatenate]]&lt;br /&gt;
* [[CPP/Strings/CountCharacters|Count characters]]&lt;br /&gt;
* [[CPP/Strings/Split|Split/parse]]&lt;br /&gt;
* [[CPP/Strings/Case_Conversion|Case conversion]]&lt;br /&gt;
* [[CPP/Strings/SingleCharacterTag|Find the contents of a single character tag]]&lt;br /&gt;
* [[CPP/Strings/FindAndReplace|Replace a substring with a replacement string (find and replace)]]&lt;br /&gt;
* [[CPP/Strings/Find|Find the position of a substring]]&lt;br /&gt;
* [[CPP/Strings/DetectPunctuation|Detect punctuation (ispunct)]]&lt;br /&gt;
&lt;br /&gt;
=== Classes ===&lt;br /&gt;
* [[CPP/Classes/ConstructorInheritance|Constructor inheritance]]&lt;br /&gt;
* [[CPP/Classes/InitializationList|Initialization list]]&lt;br /&gt;
* [[CPP/Classes/DerivedClass|Derived class]]&lt;br /&gt;
* [[CPP/Classes/DownCasting|Down casting]]&lt;br /&gt;
* [[CPP/Classes/FriendClass|Friend class]]&lt;br /&gt;
* [[CPP/Classes/NestedClasses|Nested classes]]&lt;br /&gt;
* [[CPP/Classes/PureVirtualFunction|Pure virtual function]]&lt;br /&gt;
* [[CPP/Classes/Singleton|Singleton]]&lt;br /&gt;
* [[CPP/Classes/Conversion Function|Conversion Function]]&lt;br /&gt;
&lt;br /&gt;
=== Templates ===&lt;br /&gt;
* [[CPP/Templates/FunctionTemplateHeaderOnly|Function template (header only)]]&lt;br /&gt;
* [[CPP/Templates/FunctionTemplateExplicitInstantiation|Function template (explicit instantiation)]]&lt;br /&gt;
* [[CPP/FunctionTemplateSpecialization|Function template specialization]]&lt;br /&gt;
* [[CPP/Templates/ClassTemplateHeaderOnly|Class template (header only)]]&lt;br /&gt;
* [[CPP/Templates/ClassTemplateExplicitInstantiation|Class template (explicit instantiation)]]&lt;br /&gt;
* [[CPP/Templates/MemberFunctionTemplate|A member function template]]&lt;br /&gt;
* [[CPP/Templates/PartialClassSpecialization|Partially specialize a class template]]&lt;br /&gt;
&lt;br /&gt;
=== Loops ===&lt;br /&gt;
* [[CPP/Loops/DoWhile|Do while]]&lt;br /&gt;
* [[CPP/Loops/While|While]]&lt;br /&gt;
* [[CPP/Loops/For|For]]&lt;br /&gt;
&lt;br /&gt;
=== STL Data Structures ===&lt;br /&gt;
*[[CPP/STL/Complex|Complex]]&lt;br /&gt;
*[[CPP/STL/Heap|Heap]]&lt;br /&gt;
*[[CPP/STL/List|List]]&lt;br /&gt;
*[[CPP/STL/Map|Map]]&lt;br /&gt;
*[[CPP/STL/MultiMap|MultiMap]]&lt;br /&gt;
*[[CPP/STL/MultiSet|MultiSet]]&lt;br /&gt;
*[[CPP/STL/Pair|Pair]]&lt;br /&gt;
*[[CPP/STL/PriorityQueue|Priority queue]]&lt;br /&gt;
*[[CPP/STL/Queue|Queue]]&lt;br /&gt;
*[[CPP/STL/Stack|Stack]]&lt;br /&gt;
*[[CPP/STL/String|String]]&lt;br /&gt;
*[[CPP/STL/Tuple|Tuple]]&lt;br /&gt;
*[[CPP/STL/IteratorFromObject|Iterator from object]]&lt;br /&gt;
&lt;br /&gt;
==== Vector ====&lt;br /&gt;
*[[CPP/STL/Vector|Vector]]&lt;br /&gt;
*[[CPP/STL/Vector/RemoveElement|Remove an element from a vector]]&lt;br /&gt;
*[[CPP/STL/Vector/Reverse|Reverse the elements in a vector]]&lt;br /&gt;
&lt;br /&gt;
==== Set ====&lt;br /&gt;
*[[CPP/STL/Set|Set]]&lt;br /&gt;
*[[CPP/STL/Set/RemoveElement|Remove an element from a set]]&lt;br /&gt;
*[[CPP/STL/Set/MergeSets|Merge sets]]&lt;br /&gt;
*[[CPP/STL/Set/SearchForElement|Search for an element (find)]]&lt;br /&gt;
*[[CPP/STL/Set/SetCustomClass|Custom class]]&lt;br /&gt;
*[[CPP/STL/Set/SetCustomComparison|Custom comparison operator]]&lt;br /&gt;
&lt;br /&gt;
=== STL Algorithms ===&lt;br /&gt;
* [[CPP/STL/RandomShuffle|Random shuffle]]&lt;br /&gt;
* [[CPP/STL/Sort|Sort a vector]]&lt;br /&gt;
* [[CPP/STL/SetDifference|Find the different elements in two containers (set_difference)]]&lt;br /&gt;
* [[CPP/STL/RandomData|Random data (std::generate)]]&lt;br /&gt;
* [[CPP/STL/ForEach|ForEach]]&lt;br /&gt;
* [[CPP/STL/VectorMinAndMax|VectorMinAndMax]]&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* [[CPP/Debugging/Assert|Assert]]&lt;br /&gt;
* [[CPP/Debugging/LineNumbers|LineNumbers]]&lt;br /&gt;
&lt;br /&gt;
=== C++ TR1 ===&lt;br /&gt;
*[[CPP/TR1/Regex_Tokenising|Tokenising with RegEx]]&lt;br /&gt;
&lt;br /&gt;
=== C++0x ===&lt;br /&gt;
*[[CPP/C++0x/TheBigFive|The Big Five]]&lt;br /&gt;
*[[CPP/C++0x/VectorInitialization|Vector initialization]]&lt;br /&gt;
*[[CPP/C++0x/VectorMinMax|VectorMinMax]]&lt;br /&gt;
*[[CPP/C++0x/Hash|Hash]]&lt;br /&gt;
*[[CPP/C++0x/UnorderedSet|Unordered set]]&lt;br /&gt;
&lt;br /&gt;
=== Math ===&lt;br /&gt;
*[[CPP/Math/Exponential|Exponential function]]&lt;br /&gt;
*[[CPP/Math/MinMax|Min and Max]]&lt;br /&gt;
*[[CPP/Math/Trig|Trig functions]]&lt;br /&gt;
*[[CPP/Math/SumVector|Sum elements in a vector]]&lt;br /&gt;
*[[CPP/Math/Pi|Mathematic constant Pi = 3.14...]]&lt;br /&gt;
&lt;br /&gt;
=== C-Style Programming Techniques ===&lt;br /&gt;
* [[CPP/Array|Array]]&lt;br /&gt;
* [[CPP/2DArray|2D Array]]&lt;br /&gt;
* [[CPP/CharacterArray|Character array]]&lt;br /&gt;
* [[CPP/Macros|Macros]]&lt;br /&gt;
* [[CPP/FunctionPointer|Function pointer]]&lt;br /&gt;
* [[CPP/VariableNumberOfArguments|Variable number of function arguments]]&lt;br /&gt;
&lt;br /&gt;
=== Utility ===&lt;br /&gt;
* [[CPP/Template Print|Generic Print]]&lt;br /&gt;
* [[CPP/DataType Converter | Generic DataType Converter]]&lt;br /&gt;
* [[CPP/Sockets | Sockets]]&lt;br /&gt;
* [[CPP/PThreads | PThreads]]&lt;br /&gt;
* [[CPP/TCPSocket | TCPSocket]]&lt;br /&gt;
* [[CPP/Typeof | Typeof]]&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/User_talk:Mikael.s.persson</id>
		<title>User talk:Mikael.s.persson</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/User_talk:Mikael.s.persson"/>
				<updated>2011-07-21T00:41:03Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: /* auto */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Thanks ==&lt;br /&gt;
Mikael,&lt;br /&gt;
&lt;br /&gt;
Thank you for the contributions! Please keep up the good work!&lt;br /&gt;
&lt;br /&gt;
[[User:Daviddoria|Daviddoria]] 12:32, 1 December 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
Hi Mike,&lt;br /&gt;
I saw you changed std::auto_ptr to std::unique_ptr. Could you explain the difference? Or show the difference in one or more examples? [[User:Daviddoria|Daviddoria]] 14:15, 6 April 2011 (UTC)&lt;br /&gt;
&lt;br /&gt;
auto_ptr is deprecated by unique_ptr, that's all. Mike.&lt;br /&gt;
&lt;br /&gt;
== auto ==&lt;br /&gt;
Mikael,&lt;br /&gt;
&lt;br /&gt;
I saw that you converted a couple of examples to use 'auto'. Isn't this a c++0x thing? If it is, I think we should leave it explicit so that it will work for everyone, but add a comment and the line you added as a comment about how this is the &amp;quot;new way&amp;quot; to do things. What do you think? [[User:Daviddoria|Daviddoria]] 21:20, 20 July 2011 (UTC)&lt;br /&gt;
&lt;br /&gt;
David,&lt;br /&gt;
These were examples from the C++0x section. That's why I made them a bit more C++0x-like. By the way, there might be additions to this section as we might be preparing a set of C++0x tutorials, for Daniweb.[[User:Mikael.s.persson|Mikael]]&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP/C%2B%2B0x/UnorderedSet</id>
		<title>CPP/C++0x/UnorderedSet</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP/C%2B%2B0x/UnorderedSet"/>
				<updated>2011-07-20T19:07:21Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: /* UnorderedSet.cpp */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==UnorderedSet.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;unordered_set&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// must use -std=c++0x flag&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
  // Create a set&lt;br /&gt;
  std::unordered_set&amp;lt;unsigned int&amp;gt; S;&lt;br /&gt;
&lt;br /&gt;
  // Add 10 elements to the set&lt;br /&gt;
  for(unsigned int i = 0; i &amp;lt; 10; i++)&lt;br /&gt;
  {&lt;br /&gt;
    S.insert(i);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // Output all of the elements in the set&lt;br /&gt;
  for(auto it1 = S.cbegin(); it1 != S.cend(); it1++)&lt;br /&gt;
  {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; &amp;quot; &amp;lt;&amp;lt; *it1;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==CMakeLists.txt==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
cmake_minimum_required(VERSION 2.6)&lt;br /&gt;
&lt;br /&gt;
Project(UnorderedSet)&lt;br /&gt;
ADD_EXECUTABLE(UnorderedSet UnorderedSet.cpp)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP/C%2B%2B0x/VectorMinMax</id>
		<title>CPP/C++0x/VectorMinMax</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP/C%2B%2B0x/VectorMinMax"/>
				<updated>2011-07-20T19:06:04Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: /* VectorMinMax.cpp */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==VectorMinMax.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;algorithm&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  // Vector initialization&lt;br /&gt;
  std::vector&amp;lt;int&amp;gt; v = {1,2,3};&lt;br /&gt;
&lt;br /&gt;
  auto minmax = std::minmax_element(v.begin(), v.end());&lt;br /&gt;
&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; *(minmax.first) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; *(minmax.second) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==CMakeLists.txt==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
cmake_minimum_required(VERSION 2.6)&lt;br /&gt;
&lt;br /&gt;
PROJECT(VectorMinMax)&lt;br /&gt;
&lt;br /&gt;
ADD_EXECUTABLE(VectorMinMax VectorMinMax.cpp )&lt;br /&gt;
&lt;br /&gt;
SET(CMAKE_CXX_FLAGS &amp;quot;${CMAKE_CXX_FLAGS} -Wall -std=c++0x&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/User_talk:Mikael.s.persson</id>
		<title>User talk:Mikael.s.persson</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/User_talk:Mikael.s.persson"/>
				<updated>2011-04-06T14:22:11Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Mikael,&lt;br /&gt;
&lt;br /&gt;
Thank you for the contributions! Please keep up the good work!&lt;br /&gt;
&lt;br /&gt;
[[User:Daviddoria|Daviddoria]] 12:32, 1 December 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
Hi Mike,&lt;br /&gt;
I saw you changed std::auto_ptr to std::unique_ptr. Could you explain the difference? Or show the difference in one or more examples? [[User:Daviddoria|Daviddoria]] 14:15, 6 April 2011 (UTC)&lt;br /&gt;
&lt;br /&gt;
auto_ptr is deprecated by unique_ptr, that's all. Mike.&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP</id>
		<title>CPP</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP"/>
				<updated>2011-04-06T14:15:03Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: /* General Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= C++ =&lt;br /&gt;
A statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as a &amp;quot;middle-level&amp;quot; language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell Labs as an enhancement to the C programming language and originally named C with Classes. It was renamed C++ in 1983. (http://en.wikipedia.org/wiki/C++)&lt;br /&gt;
----&lt;br /&gt;
=== Formatting ===&lt;br /&gt;
* [[CPP/Formatting/Decimals|Number of decimals (fixed and setprecision)]]&lt;br /&gt;
&lt;br /&gt;
=== General Examples ===&lt;br /&gt;
* [[CPP/auto_ptr|unique_ptr]]&lt;br /&gt;
* [[CPP/Functor|Functor]]&lt;br /&gt;
* [[CPP/ReturnByReference|Return a value by reference]]&lt;br /&gt;
* [[CPP/IntToHex|Convert an int to hex]]&lt;br /&gt;
* [[CPP/HexToInt|Convert a hex number to an int]]&lt;br /&gt;
* [[CPP/AnonymousNamespace|Anonymous namespace]]&lt;br /&gt;
* [[CPP/2DVector|2D Vector]]&lt;br /&gt;
* [[CPP/AlphebetizeString|Alphabetize a vector of strings]]&lt;br /&gt;
* [[CPP/ZeroPad|Pad a number with zeros]]&lt;br /&gt;
* [[CPP/BinaryIO|Binary input and output]]&lt;br /&gt;
* [[CPP/ExecuteLinuxCommand|Execute a linux command]]&lt;br /&gt;
* [[CPP/Casting|Casting]]&lt;br /&gt;
* [[CPP/KeyboardInput|Keyboard input]]&lt;br /&gt;
* [[CPP/CommandLineArguments|Command line arguments]]&lt;br /&gt;
* [[CPP/DeepCopy|Deep copy]]&lt;br /&gt;
* [[CPP/DefaultArguments|Default arguments]]&lt;br /&gt;
* [[CPP/Enum|Enum]]&lt;br /&gt;
* [[CPP/Exceptions|Exceptions (try/catch)]]&lt;br /&gt;
* [[CPP/Infinity|Infinity]]&lt;br /&gt;
* [[CPP/Logging|Logging]]&lt;br /&gt;
* [[CPP/Namespaces|Namespaces]]&lt;br /&gt;
* [[CPP/NAN|NAN (not a number)]]&lt;br /&gt;
* [[CPP/OverloadOperator|Overload operator]]&lt;br /&gt;
* [[CPP/ParallelSort|Parallel sort]]&lt;br /&gt;
* [[CPP/RandomNumbers|Random numbers]]&lt;br /&gt;
* [[CPP/StringStream|StringStream]]&lt;br /&gt;
* [[CPP/Struct|Struct]]&lt;br /&gt;
* [[CPP/Switch|Switch]]&lt;br /&gt;
* [[CPP/Typedef|Typedef]]&lt;br /&gt;
* [[CPP/KeepSortedList|Keeping a Sorted List of Custom Records]]&lt;br /&gt;
&lt;br /&gt;
=== I/O ===&lt;br /&gt;
* [[CPP/IO/Setw|Column width (setw)]]&lt;br /&gt;
* [[CPP/IO/FileInput|File input]]&lt;br /&gt;
* [[CPP/IO/FileOutput|File output]]&lt;br /&gt;
* [[CPP/IO/ReadingLines|Reading lines from a text file]]&lt;br /&gt;
&lt;br /&gt;
=== Strings ===&lt;br /&gt;
* [[CPP/Strings/Compare|Compare strings]]&lt;br /&gt;
* [[CPP/Strings/Concatenate|Concatenate]]&lt;br /&gt;
* [[CPP/Strings/CountCharacters|Count characters]]&lt;br /&gt;
* [[CPP/Strings/Split|Split/parse]]&lt;br /&gt;
* [[CPP/Strings/Case_Conversion|Case conversion]]&lt;br /&gt;
* [[CPP/Strings/SingleCharacterTag|Find the contents of a single character tag]]&lt;br /&gt;
* [[CPP/Strings/FindAndReplace|Replace a substring with a replacement string (find and replace)]]&lt;br /&gt;
* [[CPP/Strings/Find|Find the position of a substring]]&lt;br /&gt;
* [[CPP/Strings/DetectPunctuation|Detect punctuation (ispunct)]]&lt;br /&gt;
&lt;br /&gt;
=== Classes ===&lt;br /&gt;
* [[CPP/Classes/ConstructorInheritance|Constructor inheritance]]&lt;br /&gt;
* [[CPP/Classes/InitializationList|Initialization list]]&lt;br /&gt;
* [[CPP/Classes/DerivedClass|Derived class]]&lt;br /&gt;
* [[CPP/Classes/DownCasting|Down casting]]&lt;br /&gt;
* [[CPP/Classes/FriendClass|Friend class]]&lt;br /&gt;
* [[CPP/Classes/NestedClasses|Nested classes]]&lt;br /&gt;
* [[CPP/Classes/PureVirtualFunction|Pure virtual function]]&lt;br /&gt;
* [[CPP/Classes/Singleton|Singleton]]&lt;br /&gt;
* [[CPP/Classes/Conversion Function|Conversion Function]]&lt;br /&gt;
&lt;br /&gt;
=== Templates ===&lt;br /&gt;
* [[CPP/Templates/FunctionTemplateHeaderOnly|Function template (header only)]]&lt;br /&gt;
* [[CPP/Templates/FunctionTemplateExplicitInstantiation|Function template (explicit instantiation)]]&lt;br /&gt;
* [[CPP/FunctionTemplateSpecialization|Function template specialization]]&lt;br /&gt;
* [[CPP/Templates/ClassTemplateHeaderOnly|Class template (header only)]]&lt;br /&gt;
* [[CPP/Templates/ClassTemplateExplicitInstantiation|Class template (explicit instantiation)]]&lt;br /&gt;
* [[CPP/Templates/MemberFunctionTemplate|A member function template]]&lt;br /&gt;
* [[CPP/Templates/PartialClassSpecialization|Partially specialize a class template]]&lt;br /&gt;
&lt;br /&gt;
=== Loops ===&lt;br /&gt;
* [[CPP/Loops/DoWhile|Do while]]&lt;br /&gt;
* [[CPP/Loops/While|While]]&lt;br /&gt;
* [[CPP/Loops/For|For]]&lt;br /&gt;
&lt;br /&gt;
=== STL Data Structures ===&lt;br /&gt;
*[[CPP/STL/Complex|Complex]]&lt;br /&gt;
*[[CPP/STL/Heap|Heap]]&lt;br /&gt;
*[[CPP/STL/List|List]]&lt;br /&gt;
*[[CPP/STL/Map|Map]]&lt;br /&gt;
*[[CPP/STL/MultiMap|MultiMap]]&lt;br /&gt;
*[[CPP/STL/MultiSet|MultiSet]]&lt;br /&gt;
*[[CPP/STL/Pair|Pair]]&lt;br /&gt;
*[[CPP/STL/PriorityQueue|Priority queue]]&lt;br /&gt;
*[[CPP/STL/Queue|Queue]]&lt;br /&gt;
*[[CPP/STL/Stack|Stack]]&lt;br /&gt;
*[[CPP/STL/String|String]]&lt;br /&gt;
*[[CPP/STL/Tuple|Tuple]]&lt;br /&gt;
*[[CPP/STL/IteratorFromObject|Iterator from object]]&lt;br /&gt;
&lt;br /&gt;
==== Vector ====&lt;br /&gt;
*[[CPP/STL/Vector|Vector]]&lt;br /&gt;
*[[CPP/STL/Vector/RemoveElement|Remove an element from a vector]]&lt;br /&gt;
&lt;br /&gt;
==== Set ====&lt;br /&gt;
*[[CPP/STL/Set|Set]]&lt;br /&gt;
*[[CPP/STL/Set/RemoveElement|Remove an element from a set]]&lt;br /&gt;
*[[CPP/STL/Set/MergeSets|Merge sets]]&lt;br /&gt;
*[[CPP/STL/Set/SearchForElement|Search for an element (find)]]&lt;br /&gt;
*[[CPP/STL/Set/SetCustomClass|Custom class]]&lt;br /&gt;
*[[CPP/STL/Set/SetCustomComparison|Custom comparison operator]]&lt;br /&gt;
&lt;br /&gt;
=== STL Algorithms ===&lt;br /&gt;
* [[CPP/STL/RandomShuffle|Random shuffle]]&lt;br /&gt;
* [[CPP/STL/Sort|Sort a vector]]&lt;br /&gt;
* [[CPP/STL/SetDifference|Find the different elements in two containers (set_difference)]]&lt;br /&gt;
* [[CPP/STL/RandomData|Random data (std::generate)]]&lt;br /&gt;
* [[CPP/STL/ForEach|ForEach]]&lt;br /&gt;
* [[CPP/STL/VectorMinAndMax|VectorMinAndMax]]&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* [[CPP/Debugging/Assert|Assert]]&lt;br /&gt;
* [[CPP/Debugging/LineNumbers|LineNumbers]]&lt;br /&gt;
&lt;br /&gt;
=== C++ TR1 ===&lt;br /&gt;
*[[CPP/TR1/Regex_Tokenising|Tokenising with RegEx]]&lt;br /&gt;
&lt;br /&gt;
=== C++0x ===&lt;br /&gt;
*[[CPP/C++0x/VectorInitialization|Vector initialization]]&lt;br /&gt;
*[[CPP/C++0x/VectorMinMax|VectorMinMax]]&lt;br /&gt;
*[[CPP/C++0x/Hash|Hash]]&lt;br /&gt;
*[[CPP/C++0x/UnorderedSet|Unordered set]]&lt;br /&gt;
&lt;br /&gt;
=== Math ===&lt;br /&gt;
*[[CPP/Math/Exponential|Exponential function]]&lt;br /&gt;
*[[CPP/Math/MinMax|Min and Max]]&lt;br /&gt;
*[[CPP/Math/Trig|Trig functions]]&lt;br /&gt;
*[[CPP/Math/SumVector|Sum elements in a vector]]&lt;br /&gt;
&lt;br /&gt;
=== C-Style Programming Techniques ===&lt;br /&gt;
* [[CPP/Array|Array]]&lt;br /&gt;
* [[CPP/2DArray|2D Array]]&lt;br /&gt;
* [[CPP/CharacterArray|Character array]]&lt;br /&gt;
* [[CPP/Macros|Macros]]&lt;br /&gt;
* [[CPP/FunctionPointer|Function pointer]]&lt;br /&gt;
* [[CPP/VariableNumberOfArguments|Variable number of function arguments]]&lt;br /&gt;
&lt;br /&gt;
=== Utility ===&lt;br /&gt;
* [[CPP/Template Print|Generic Print]]&lt;br /&gt;
* [[CPP/DataType Converter | Generic DataType Converter]]&lt;br /&gt;
* [[CPP/Sockets | Sockets]]&lt;br /&gt;
* [[CPP/PThreads | PThreads]]&lt;br /&gt;
* [[CPP/TCPSocket | TCPSocket]]&lt;br /&gt;
* [[CPP/Typeof | Typeof]]&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP/unique_ptr</id>
		<title>CPP/unique ptr</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP/unique_ptr"/>
				<updated>2011-04-06T14:14:32Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: /* CMakeLists.txt */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==unique_ptr.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;memory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
  std::unique_ptr&amp;lt;int&amp;gt; myInt(new int);&lt;br /&gt;
  *myInt = 5;&lt;br /&gt;
&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; *myInt &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==CMakeLists.txt==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
cmake_minimum_required(VERSION 2.6)&lt;br /&gt;
&lt;br /&gt;
PROJECT(unique_ptr)&lt;br /&gt;
ADD_EXECUTABLE(unique_ptr unique_ptr.cpp)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP/unique_ptr</id>
		<title>CPP/unique ptr</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP/unique_ptr"/>
				<updated>2011-04-06T14:14:15Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: /* unique_ptr.cpp */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==unique_ptr.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;memory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
  std::unique_ptr&amp;lt;int&amp;gt; myInt(new int);&lt;br /&gt;
  *myInt = 5;&lt;br /&gt;
&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; *myInt &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==CMakeLists.txt==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
cmake_minimum_required(VERSION 2.6)&lt;br /&gt;
&lt;br /&gt;
PROJECT(auto_ptr)&lt;br /&gt;
ADD_EXECUTABLE(auto_ptr auto_ptr.cpp)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP/Templates/PartialClassSpecialization</id>
		<title>CPP/Templates/PartialClassSpecialization</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP/Templates/PartialClassSpecialization"/>
				<updated>2011-04-06T14:08:26Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: /* Point.h */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==PartialClassSpecialization.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Point.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   Point&amp;lt;int, int, double&amp;gt; a;&lt;br /&gt;
   Point&amp;lt;int, int*, 5&amp;gt; b;&lt;br /&gt;
&lt;br /&gt;
   a.function1();&lt;br /&gt;
   b.function1();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Point.h==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef POINT_H&lt;br /&gt;
#define POINT_H&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
&lt;br /&gt;
template&amp;lt;typename T, typename U&amp;gt;&lt;br /&gt;
class Point&lt;br /&gt;
{&lt;br /&gt;
  void function1();&lt;br /&gt;
  void function2();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
template&amp;lt;typename T&amp;gt;&lt;br /&gt;
class Point&amp;lt;T, int&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  void function1();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Point.txx&amp;quot;&lt;br /&gt;
template&amp;lt;typename T, typename U&amp;gt;&lt;br /&gt;
void Point&amp;lt;T,U&amp;gt;::function1()&lt;br /&gt;
{&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;Primary template function1&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
template&amp;lt;typename T, typename U&amp;gt;&lt;br /&gt;
void Point&amp;lt;T,U&amp;gt;::function2()&lt;br /&gt;
{&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;Primary template function2&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//////////////////&lt;br /&gt;
template&amp;lt;class T&amp;gt;&lt;br /&gt;
void Point&amp;lt;T, int&amp;gt;::function1()&lt;br /&gt;
{&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;Partial specialization function1&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
}&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Point.txx==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==CMakeLists.txt==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
Project(PartialClassSpecialization)&lt;br /&gt;
&lt;br /&gt;
ADD_EXECUTABLE(PartialClassSpecialization PartialClassSpecialization.cpp)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP/KeepSortedList</id>
		<title>CPP/KeepSortedList</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP/KeepSortedList"/>
				<updated>2010-12-05T04:28:05Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: Keeping a Sorted List of Custom Records&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==PhoneBook.cpp==&lt;br /&gt;
In the following example, a custom record class (a phone record) is kept in a sorted list (std::set) for fast look-ups (binary search). The example shows how to create the proper overloaded operators required by the STL container and how to use the set to add records and find records based on names.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;set&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
class PhoneRecord {&lt;br /&gt;
  private:&lt;br /&gt;
    std::string last_name;&lt;br /&gt;
    std::string first_name;&lt;br /&gt;
    std::string phone_number;&lt;br /&gt;
  public:&lt;br /&gt;
    //using default arguments allows for both a default constructor and partial construction:&lt;br /&gt;
    PhoneRecord(const std::string&amp;amp; aLastName = &amp;quot;&amp;quot;,const std::string&amp;amp; aFirstName = &amp;quot;&amp;quot;,const std::string&amp;amp; aPhoneNumber = &amp;quot;&amp;quot;) : last_name(aLastName), first_name(aFirstName), phone_number(aPhoneNumber) { };&lt;br /&gt;
    ~PhoneRecord() { };&lt;br /&gt;
    //a copy-constructor is needed for the STL container:&lt;br /&gt;
    PhoneRecord(const PhoneRecord&amp;amp; aObj) : last_name(aObj.last_name), first_name(aObj.first_name), phone_number(aObj.phone_number) { };&lt;br /&gt;
&lt;br /&gt;
    //an assignment operator is needed for the STL container:&lt;br /&gt;
    PhoneRecord&amp;amp; operator=(const PhoneRecord&amp;amp; aObj) {&lt;br /&gt;
      last_name = aObj.last_name;&lt;br /&gt;
      first_name = aObj.first_name;&lt;br /&gt;
      phone_number = aObj.phone_number;&lt;br /&gt;
      return *this;&lt;br /&gt;
    };&lt;br /&gt;
    //this is the overloaded operators you need for having an ordered set:&lt;br /&gt;
    bool operator &amp;lt;(const PhoneRecord&amp;amp; aObj) const {&lt;br /&gt;
      if(last_name &amp;lt; aObj.last_name) //sort by last name first&lt;br /&gt;
        return true;&lt;br /&gt;
      else if(last_name == aObj.last_name)&lt;br /&gt;
        return (first_name &amp;lt; aObj.first_name); //then, sort by first names&lt;br /&gt;
      else&lt;br /&gt;
        return false;&lt;br /&gt;
    };&lt;br /&gt;
    bool operator ==(const PhoneRecord&amp;amp; aObj) const {&lt;br /&gt;
      return ((last_name == aObj.last_name) &amp;amp;&amp;amp; (first_name == aObj.first_name)); //only require the names to be the same for equality.&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    //to be able to print, you need the following friend operator:&lt;br /&gt;
    friend std::ostream&amp;amp; operator&amp;lt;&amp;lt;(std::ostream&amp;amp; out, const PhoneRecord&amp;amp; aObj);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
//Create a printing operator for the standard output stream (ostream).&lt;br /&gt;
std::ostream&amp;amp; operator&amp;lt;&amp;lt;(std::ostream&amp;amp; out, const PhoneRecord&amp;amp; aObj) {&lt;br /&gt;
  return out &amp;lt;&amp;lt; &amp;quot;Name: &amp;quot; &amp;lt;&amp;lt; aObj.last_name &amp;lt;&amp;lt; &amp;quot;, &amp;quot; &amp;lt;&amp;lt; aObj.first_name &amp;lt;&amp;lt; &amp;quot;\t Phone Number: &amp;quot; &amp;lt;&amp;lt; aObj.phone_number;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
  std::set&amp;lt;PhoneRecord&amp;gt; phone_book;&lt;br /&gt;
  //add a bunch of records, in random order:&lt;br /&gt;
  phone_book.insert(PhoneRecord(&amp;quot;Smith&amp;quot;,&amp;quot;James&amp;quot;,&amp;quot;555-7624&amp;quot;));&lt;br /&gt;
  phone_book.insert(PhoneRecord(&amp;quot;Doe&amp;quot;,&amp;quot;John&amp;quot;,&amp;quot;555-3424&amp;quot;));&lt;br /&gt;
  phone_book.insert(PhoneRecord(&amp;quot;Doe&amp;quot;,&amp;quot;Jane&amp;quot;,&amp;quot;555-9803&amp;quot;));&lt;br /&gt;
  &lt;br /&gt;
  //print the list out:&lt;br /&gt;
  std::set&amp;lt;PhoneRecord&amp;gt;::iterator it = phone_book.begin();&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;The phone book is now:&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  for(;it != phone_book.end();++it)&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; (*it) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
&lt;br /&gt;
  //find a particular entry by name:&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;Now looking for John Doe...&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  it = phone_book.find(PhoneRecord(&amp;quot;Doe&amp;quot;,&amp;quot;John&amp;quot;)); //notice no need for phone number.&lt;br /&gt;
  if(it != phone_book.end())&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Found: &amp;quot; &amp;lt;&amp;lt; (*it) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  else&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Could not find John Doe!&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP</id>
		<title>CPP</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP"/>
				<updated>2010-12-05T04:21:59Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: /* Programming Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= C++ =&lt;br /&gt;
A statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as a &amp;quot;middle-level&amp;quot; language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell Labs as an enhancement to the C programming language and originally named C with Classes. It was renamed C++ in 1983. (http://en.wikipedia.org/wiki/C++)&lt;br /&gt;
----&lt;br /&gt;
=== Programming Examples ===&lt;br /&gt;
* [[CPP/AnonymousNamespace|Anonymous namespace]]&lt;br /&gt;
* [[CPP/2DVector|2D Vector]]&lt;br /&gt;
* [[CPP/AlphebetizeString|Alphabetize a vector of strings]]&lt;br /&gt;
* [[CPP/ZeroPad|Pad a number with zeros]]&lt;br /&gt;
* [[CPP/BinaryIO|Binary input and output]]&lt;br /&gt;
* [[CPP/ExecuteLinuxCommand|Execute a linux command]]&lt;br /&gt;
* [[CPP/Casting|Casting]]&lt;br /&gt;
* [[CPP/KeyboardInput|Keyboard input]]&lt;br /&gt;
* [[CPP/CommandLineArguments|Command line arguments]]&lt;br /&gt;
* [[CPP/DeepCopy|Deep copy]]&lt;br /&gt;
* [[CPP/DefaultArguments|Default arguments]]&lt;br /&gt;
* [[CPP/Enum|Enum]]&lt;br /&gt;
* [[CPP/Exceptions|Exceptions (try/catch)]]&lt;br /&gt;
* [[CPP/Infinity|Infinity]]&lt;br /&gt;
* [[CPP/Logging|Logging]]&lt;br /&gt;
* [[CPP/Namespaces|Namespaces]]&lt;br /&gt;
* [[CPP/NAN|NAN (not a number)]]&lt;br /&gt;
* [[CPP/OverloadOperator|Overload operator]]&lt;br /&gt;
* [[CPP/ParallelSort|Parallel sort]]&lt;br /&gt;
* [[CPP/RandomNumbers|Random numbers]]&lt;br /&gt;
* [[CPP/StringStream|StringStream]]&lt;br /&gt;
* [[CPP/Struct|Struct]]&lt;br /&gt;
* [[CPP/Switch|Switch]]&lt;br /&gt;
* [[CPP/Typedef|Typedef]]&lt;br /&gt;
* [[CPP/KeepSortedList|Keeping a Sorted List of Custom Records]]&lt;br /&gt;
&lt;br /&gt;
=== I/O ===&lt;br /&gt;
* [[CPP/IO/Setw|Column width (setw)]]&lt;br /&gt;
* [[CPP/IO/FileInput|File input]]&lt;br /&gt;
* [[CPP/IO/FileOutput|File output]]&lt;br /&gt;
* [[CPP/IO/ReadingLines|Reading lines from a text file]]&lt;br /&gt;
&lt;br /&gt;
=== Strings ===&lt;br /&gt;
* [[CPP/Strings/Compare|Compare strings]]&lt;br /&gt;
* [[CPP/Strings/Concatenate|Concatenate]]&lt;br /&gt;
* [[CPP/Strings/CountCharacters|Count characters]]&lt;br /&gt;
* [[CPP/Strings/Split|Split/parse]]&lt;br /&gt;
* [[CPP/Strings/Case_Conversion|Case conversion]]&lt;br /&gt;
* [[CPP/Strings/SingleCharacterTag|Find the contents of a single character tag]]&lt;br /&gt;
* [[CPP/Strings/FindAndReplace|Replace a substring with a replacement string (find and replace)]]&lt;br /&gt;
&lt;br /&gt;
=== Classes ===&lt;br /&gt;
* [[CPP/Classes/ClassTemplate|Class template]]&lt;br /&gt;
* [[CPP/Classes/ConstructorInheritance|Constructor inheritance]]&lt;br /&gt;
* [[CPP/Classes/InitializationList|Initialization list]]&lt;br /&gt;
* [[CPP/Classes/DerivedClass|Derived class]]&lt;br /&gt;
* [[CPP/Classes/DownCasting|Down casting]]&lt;br /&gt;
* [[CPP/Classes/FriendClass|Friend class]]&lt;br /&gt;
* [[CPP/Classes/NestedClasses|Nested classes]]&lt;br /&gt;
* [[CPP/Classes/PureVirtualFunction|Pure virtual function]]&lt;br /&gt;
* [[CPP/Classes/Singleton|Singleton]]&lt;br /&gt;
* [[CPP/Classes/Conversion Function|Conversion Function]]&lt;br /&gt;
&lt;br /&gt;
=== Loops ===&lt;br /&gt;
* [[CPP/Loops/DoWhile|Do while]]&lt;br /&gt;
* [[CPP/Loops/While|While]]&lt;br /&gt;
* [[CPP/Loops/For|For]]&lt;br /&gt;
&lt;br /&gt;
=== STL Data Structures ===&lt;br /&gt;
*[[CPP/STL/String|String]]&lt;br /&gt;
*[[CPP/STL/Vector|Vector]]&lt;br /&gt;
*[[CPP/STL/List|List]]&lt;br /&gt;
*[[CPP/STL/Set|Set]]&lt;br /&gt;
*[[CPP/STL/MultiSet|MultiSet]]&lt;br /&gt;
*[[CPP/STL/Map|Map]]&lt;br /&gt;
*[[CPP/STL/MultiMap|MultiMap]]&lt;br /&gt;
*[[CPP/STL/Pair|Pair]]&lt;br /&gt;
*[[CPP/STL/PriorityQueue|Priority queue]]&lt;br /&gt;
*[[CPP/STL/Queue|Queue]]&lt;br /&gt;
*[[CPP/STL/Tuple|Tuple]]&lt;br /&gt;
*[[CPP/STL/Stack|Stack]]&lt;br /&gt;
*[[CPP/STL/Heap|Heap]]&lt;br /&gt;
&lt;br /&gt;
=== STL Algorithms ===&lt;br /&gt;
* [[CPP/STL/RandomShuffle|Random shuffle]]&lt;br /&gt;
* [[CPP/STL/Sort|Sort a vector]]&lt;br /&gt;
* [[CPP/STL/SetDifference|Find the different elements in two containers (set_difference)]]&lt;br /&gt;
* [[CPP/STL/RandomData|Random data (std::generate)]]&lt;br /&gt;
* [[CPP/STL/ForEach|ForEach]]&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* [[CPP/Debugging/Assert|Assert]]&lt;br /&gt;
* [[CPP/Debugging/LineNumbers|LineNumbers]]&lt;br /&gt;
&lt;br /&gt;
=== C++ TR1 ===&lt;br /&gt;
*[[CPP/TR1/Regex_Tokenising|Tokenising with RegEx]]&lt;br /&gt;
&lt;br /&gt;
=== C++0x ===&lt;br /&gt;
*[[CPP/C++0x/Hash|Hash]]&lt;br /&gt;
&lt;br /&gt;
=== Math ===&lt;br /&gt;
*[[CPP/Math/Exponential|Exponential function]]&lt;br /&gt;
*[[CPP/Math/MinMax|Min and Max]]&lt;br /&gt;
*[[CPP/Math/Trig|Trig functions]]&lt;br /&gt;
*[[CPP/Math/SumVector|Sum elements in a vector]]&lt;br /&gt;
&lt;br /&gt;
=== C-Style Programming Techniques ===&lt;br /&gt;
* [[CPP/Array|Array]]&lt;br /&gt;
* [[CPP/2DArray|2D Array]]&lt;br /&gt;
* [[CPP/CharacterArray|Character array]]&lt;br /&gt;
* [[CPP/Macros|Macros]]&lt;br /&gt;
* [[CPP/FunctionPointer|Function pointer]]&lt;br /&gt;
* [[CPP/VariableNumberOfArguments|Variable number of function arguments]]&lt;br /&gt;
&lt;br /&gt;
=== Boost ===&lt;br /&gt;
* [[CPP/Boost/Histogram|Create a histogram (accumulator)]]&lt;br /&gt;
* [[CPP/Boost/Numeric/Matrix|Matrix]]&lt;br /&gt;
* [[CPP/Boost/Numeric/MultiArray|Multi dimensional array]]&lt;br /&gt;
* [[CPP/Boost/ProgramOptions/Simple|Simple command line argument parsing (ProgramOptions)]]&lt;br /&gt;
* [[CPP/Boost/ProgramOptions/MultipleArguments|Multiple command line argument parsing (ProgramOptions)]]&lt;br /&gt;
* [[CPP/Boost/ProgressBar|ProgressBar]]&lt;br /&gt;
* [[CPP/Boost/Threads|Threads]]&lt;br /&gt;
* [[CPP/Boost/ThreadsMember|Threads with member functions]]&lt;br /&gt;
* [[CPP/Boost/ThreadCommunication|ThreadCommunication]]&lt;br /&gt;
* [[CPP/Boost/Timer|Timer]]&lt;br /&gt;
&lt;br /&gt;
=== Utility ===&lt;br /&gt;
* [[CPP/Template Print|Generic Print]]&lt;br /&gt;
* [[CPP/DataType Converter | Generic DataType Converter]]&lt;br /&gt;
* [[CPP/Sockets | Sockets]]&lt;br /&gt;
* [[CPP/PThreads | PThreads]]&lt;br /&gt;
* [[CPP/TCPSocket | TCPSocket]]&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP</id>
		<title>CPP</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP"/>
				<updated>2010-12-01T03:27:19Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: /* Boost */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= C++ =&lt;br /&gt;
A statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as a &amp;quot;middle-level&amp;quot; language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell Labs as an enhancement to the C programming language and originally named C with Classes. It was renamed C++ in 1983. (http://en.wikipedia.org/wiki/C++)&lt;br /&gt;
----&lt;br /&gt;
=== Programming Examples ===&lt;br /&gt;
* [[CPP/AnonymousNamespace|Anonymous namespace]]&lt;br /&gt;
* [[CPP/2DVector|2D Vector]]&lt;br /&gt;
* [[CPP/AlphebetizeString|Alphabetize a vector of strings]]&lt;br /&gt;
* [[CPP/ZeroPad|Pad a number with zeros]]&lt;br /&gt;
* [[CPP/BinaryIO|Binary input and output]]&lt;br /&gt;
* [[CPP/ExecuteLinuxCommand|Execute a linux command]]&lt;br /&gt;
* [[CPP/Casting|Casting]]&lt;br /&gt;
* [[CPP/KeyboardInput|Keyboard input]]&lt;br /&gt;
* [[CPP/CommandLineArguments|Command line arguments]]&lt;br /&gt;
* [[CPP/DeepCopy|Deep copy]]&lt;br /&gt;
* [[CPP/DefaultArguments|Default arguments]]&lt;br /&gt;
* [[CPP/Enum|Enum]]&lt;br /&gt;
* [[CPP/Exceptions|Exceptions (try/catch)]]&lt;br /&gt;
* [[CPP/Infinity|Infinity]]&lt;br /&gt;
* [[CPP/Logging|Logging]]&lt;br /&gt;
* [[CPP/Namespaces|Namespaces]]&lt;br /&gt;
* [[CPP/NAN|NAN (not a number)]]&lt;br /&gt;
* [[CPP/OverloadOperator|Overload operator]]&lt;br /&gt;
* [[CPP/ParallelSort|Parallel sort]]&lt;br /&gt;
* [[CPP/RandomNumbers|Random numbers]]&lt;br /&gt;
* [[CPP/StringStream|StringStream]]&lt;br /&gt;
* [[CPP/Struct|Struct]]&lt;br /&gt;
* [[CPP/Switch|Switch]]&lt;br /&gt;
* [[CPP/Typedef|Typedef]]&lt;br /&gt;
&lt;br /&gt;
=== I/O ===&lt;br /&gt;
* [[CPP/IO/Setw|Column width (setw)]]&lt;br /&gt;
* [[CPP/IO/FileInput|File input]]&lt;br /&gt;
* [[CPP/IO/FileOutput|File output]]&lt;br /&gt;
* [[CPP/IO/ReadingLines|Reading lines from a text file]]&lt;br /&gt;
&lt;br /&gt;
=== Strings ===&lt;br /&gt;
* [[CPP/Strings/Compare|Compare strings]]&lt;br /&gt;
* [[CPP/Strings/Concatenate|Concatenate]]&lt;br /&gt;
* [[CPP/Strings/CountCharacters|Count characters]]&lt;br /&gt;
* [[CPP/Strings/Split|Split/parse]]&lt;br /&gt;
* [[CPP/Strings/Case_Conversion|Case conversion]]&lt;br /&gt;
* [[CPP/Strings/SingleCharacterTag|Find the contents of a single character tag]]&lt;br /&gt;
* [[CPP/Strings/FindAndReplace|Replace a substring with a replacement string (find and replace)]]&lt;br /&gt;
&lt;br /&gt;
=== Classes ===&lt;br /&gt;
* [[CPP/Classes/ClassTemplate|Class template]]&lt;br /&gt;
* [[CPP/Classes/ConstructorInheritance|Constructor inheritance]]&lt;br /&gt;
* [[CPP/Classes/InitializationList|Initialization list]]&lt;br /&gt;
* [[CPP/Classes/DerivedClass|Derived class]]&lt;br /&gt;
* [[CPP/Classes/DownCasting|Down casting]]&lt;br /&gt;
* [[CPP/Classes/FriendClass|Friend class]]&lt;br /&gt;
* [[CPP/Classes/NestedClasses|Nested classes]]&lt;br /&gt;
* [[CPP/Classes/PureVirtualFunction|Pure virtual function]]&lt;br /&gt;
* [[CPP/Classes/Singleton|Singleton]]&lt;br /&gt;
* [[CPP/Classes/Conversion Function|Conversion Function]]&lt;br /&gt;
&lt;br /&gt;
=== Loops ===&lt;br /&gt;
* [[CPP/Loops/DoWhile|Do while]]&lt;br /&gt;
* [[CPP/Loops/While|While]]&lt;br /&gt;
* [[CPP/Loops/For|For]]&lt;br /&gt;
&lt;br /&gt;
=== STL Data Structures ===&lt;br /&gt;
*[[CPP/STL/String|String]]&lt;br /&gt;
*[[CPP/STL/Vector|Vector]]&lt;br /&gt;
*[[CPP/STL/List|List]]&lt;br /&gt;
*[[CPP/STL/Set|Set]]&lt;br /&gt;
*[[CPP/STL/MultiSet|MultiSet]]&lt;br /&gt;
*[[CPP/STL/Map|Map]]&lt;br /&gt;
*[[CPP/STL/MultiMap|MultiMap]]&lt;br /&gt;
*[[CPP/STL/Pair|Pair]]&lt;br /&gt;
*[[CPP/STL/PriorityQueue|Priority queue]]&lt;br /&gt;
*[[CPP/STL/Queue|Queue]]&lt;br /&gt;
*[[CPP/STL/Tuple|Tuple]]&lt;br /&gt;
*[[CPP/STL/Stack|Stack]]&lt;br /&gt;
*[[CPP/STL/Heap|Heap]]&lt;br /&gt;
&lt;br /&gt;
=== STL Algorithms ===&lt;br /&gt;
* [[CPP/STL/RandomShuffle|Random shuffle]]&lt;br /&gt;
* [[CPP/STL/Sort|Sort a vector]]&lt;br /&gt;
* [[CPP/STL/SetDifference|Find the different elements in two containers (set_difference)]]&lt;br /&gt;
* [[CPP/STL/RandomData|Random data (std::generate)]]&lt;br /&gt;
* [[CPP/STL/ForEach|ForEach]]&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* [[CPP/Debugging/Assert|Assert]]&lt;br /&gt;
* [[CPP/Debugging/LineNumbers|LineNumbers]]&lt;br /&gt;
&lt;br /&gt;
=== C++ TR1 ===&lt;br /&gt;
*[[CPP/TR1/Regex_Tokenising|Tokenising with RegEx]]&lt;br /&gt;
&lt;br /&gt;
=== C++0x ===&lt;br /&gt;
*[[CPP/C++0x/Hash|Hash]]&lt;br /&gt;
&lt;br /&gt;
=== Math ===&lt;br /&gt;
*[[CPP/Math/Exponential|Exponential function]]&lt;br /&gt;
*[[CPP/Math/MinMax|Min and Max]]&lt;br /&gt;
*[[CPP/Math/Trig|Trig functions]]&lt;br /&gt;
*[[CPP/Math/SumVector|Sum elements in a vector]]&lt;br /&gt;
&lt;br /&gt;
=== C-Style Programming Techniques ===&lt;br /&gt;
* [[CPP/Array|Array]]&lt;br /&gt;
* [[CPP/2DArray|2D Array]]&lt;br /&gt;
* [[CPP/CharacterArray|Character array]]&lt;br /&gt;
* [[CPP/Macros|Macros]]&lt;br /&gt;
* [[CPP/FunctionPointer|Function pointer]]&lt;br /&gt;
* [[CPP/VariableNumberOfArguments|Variable number of function arguments]]&lt;br /&gt;
&lt;br /&gt;
=== Boost ===&lt;br /&gt;
* [[CPP/Boost/Histogram|Create a histogram (accumulator)]]&lt;br /&gt;
* [[CPP/Boost/Numeric/Matrix|Matrix]]&lt;br /&gt;
* [[CPP/Boost/Numeric/MultiArray|Multi dimensional array]]&lt;br /&gt;
* [[CPP/Boost/ProgramOptions/Simple|Simple command line argument parsing (ProgramOptions)]]&lt;br /&gt;
* [[CPP/Boost/ProgramOptions/MultipleArguments|Multiple command line argument parsing (ProgramOptions)]]&lt;br /&gt;
* [[CPP/Boost/ProgressBar|ProgressBar]]&lt;br /&gt;
* [[CPP/Boost/Threads|Threads]]&lt;br /&gt;
* [[CPP/Boost/ThreadsMember|Threads with member functions]]&lt;br /&gt;
* [[CPP/Boost/ThreadCommunication|ThreadCommunication]]&lt;br /&gt;
* [[CPP/Boost/Timer|Timer]]&lt;br /&gt;
&lt;br /&gt;
=== Utility ===&lt;br /&gt;
* [[CPP/Template Print|Generic Print]]&lt;br /&gt;
* [[CPP/DataType Converter | Generic DataType Converter]]&lt;br /&gt;
* [[CPP/Sockets | Sockets]]&lt;br /&gt;
* [[CPP/PThreads | PThreads]]&lt;br /&gt;
* [[CPP/TCPSocket | TCPSocket]]&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP/Templates/ClassTemplateExplicitInstantiation</id>
		<title>CPP/Templates/ClassTemplateExplicitInstantiation</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP/Templates/ClassTemplateExplicitInstantiation"/>
				<updated>2010-12-01T03:12:34Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: /* Point.cpp */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==ClassTemplate.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Point.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
  Point&amp;lt;double&amp;gt; A;&lt;br /&gt;
&lt;br /&gt;
  cout &amp;lt;&amp;lt; A.Add( ) &amp;lt;&amp;lt; endl;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Point.h==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef POINT_H&lt;br /&gt;
#define POINT_H&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
template &amp;lt;typename T&amp;gt;&lt;br /&gt;
class Point&lt;br /&gt;
{&lt;br /&gt;
	T x,y,z;&lt;br /&gt;
&lt;br /&gt;
public:&lt;br /&gt;
	double Add();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
#ifdef NO_EXPLICIT_INSTANTIATION&lt;br /&gt;
&lt;br /&gt;
//must put the definition here to avoid explicit instantiation&lt;br /&gt;
template &amp;lt;typename T&amp;gt;&lt;br /&gt;
double Point&amp;lt;T&amp;gt;::Add()&lt;br /&gt;
{&lt;br /&gt;
	return 2.0 + 4.3;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Point.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;Point.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
#ifndef NO_EXPLICIT_INSTANTIATION&lt;br /&gt;
&lt;br /&gt;
//can put the definition here, however... (see below)&lt;br /&gt;
template &amp;lt;typename T&amp;gt;&lt;br /&gt;
double Point&amp;lt;T&amp;gt;::Add()&lt;br /&gt;
{&lt;br /&gt;
	return 2.0 + 4.3;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
//... you will be required to instantiate all classes you might use from this template.&lt;br /&gt;
template class Point&amp;lt;double&amp;gt;;&lt;br /&gt;
template class Point&amp;lt;float&amp;gt;;&lt;br /&gt;
//... etc.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP/Templates/ClassTemplateExplicitInstantiation</id>
		<title>CPP/Templates/ClassTemplateExplicitInstantiation</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP/Templates/ClassTemplateExplicitInstantiation"/>
				<updated>2010-12-01T03:09:44Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: /* Point.h */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==ClassTemplate.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Point.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
  Point&amp;lt;double&amp;gt; A;&lt;br /&gt;
&lt;br /&gt;
  cout &amp;lt;&amp;lt; A.Add( ) &amp;lt;&amp;lt; endl;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Point.h==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef POINT_H&lt;br /&gt;
#define POINT_H&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
template &amp;lt;typename T&amp;gt;&lt;br /&gt;
class Point&lt;br /&gt;
{&lt;br /&gt;
	T x,y,z;&lt;br /&gt;
&lt;br /&gt;
public:&lt;br /&gt;
	double Add();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
#ifdef NO_EXPLICIT_INSTANTIATION&lt;br /&gt;
&lt;br /&gt;
//must put the definition here to avoid explicit instantiation&lt;br /&gt;
template &amp;lt;typename T&amp;gt;&lt;br /&gt;
double Point&amp;lt;T&amp;gt;::Add()&lt;br /&gt;
{&lt;br /&gt;
	return 2.0 + 4.3;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Point.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;Point.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
//cannot put the definition here&lt;br /&gt;
template &amp;lt;typename T&amp;gt;&lt;br /&gt;
double Point&amp;lt;T&amp;gt;::Add()&lt;br /&gt;
{&lt;br /&gt;
	return 2.0 + 4.3;&lt;br /&gt;
}&lt;br /&gt;
*/&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP/Classes/InitializationList</id>
		<title>CPP/Classes/InitializationList</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP/Classes/InitializationList"/>
				<updated>2010-12-01T03:07:18Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: /* InitializationList.cpp */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==InitializationList.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
class IntFloatChar{&lt;br /&gt;
private:&lt;br /&gt;
  int i;&lt;br /&gt;
  float f;&lt;br /&gt;
  char c;&lt;br /&gt;
public:&lt;br /&gt;
 IntFloatChar()&lt;br /&gt;
  : i(), f(), c() //initializer list, set i,f,c to their default values (undefined for primitive types like int, float, char or any pointer type) by calling their default ctors&lt;br /&gt;
 {}&lt;br /&gt;
 IntFloatChar(int I, float F, char C)&lt;br /&gt;
  : i(I), f(F), c(C) // initializer list, set value to the passed arguments&lt;br /&gt;
 {}&lt;br /&gt;
&lt;br /&gt;
  int&amp;amp; intValue(){ return i; }&lt;br /&gt;
  float&amp;amp; floatValue(){ return f;}&lt;br /&gt;
  char&amp;amp; charValue(){ return c; }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char* argv[]){&lt;br /&gt;
  //uses initializer list to initialize data&lt;br /&gt;
  IntFloatChar crazyDataType = IntFloatChar(1,'a',0.1f);&lt;br /&gt;
  IntFloatChar whatIsThis = IntFloatChar(); &lt;br /&gt;
 &lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP/Classes/FriendClass</id>
		<title>CPP/Classes/FriendClass</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP/Classes/FriendClass"/>
				<updated>2010-12-01T03:05:40Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: /* FriendClass.cpp */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==FriendClass.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
//forward declaration    &lt;br /&gt;
class B;&lt;br /&gt;
&lt;br /&gt;
class A&lt;br /&gt;
{&lt;br /&gt;
  private:&lt;br /&gt;
    friend class B;&lt;br /&gt;
    int a;&lt;br /&gt;
    &lt;br /&gt;
  public:&lt;br /&gt;
    A(int aA) : a(aA) { };&lt;br /&gt;
  &lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class B&lt;br /&gt;
{&lt;br /&gt;
  private:&lt;br /&gt;
&lt;br /&gt;
  public:&lt;br /&gt;
    int getAa(const A&amp;amp; aObj) { return aObj.a; };&lt;br /&gt;
};&lt;br /&gt;
    &lt;br /&gt;
int main(int argc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
  A objA(42);&lt;br /&gt;
  B objB;&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;Value of A.a is &amp;quot; &amp;lt;&amp;lt; objB.getAa(objA) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP/Classes/Singleton</id>
		<title>CPP/Classes/Singleton</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP/Classes/Singleton"/>
				<updated>2010-12-01T02:53:43Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: /* Singleton.cpp */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Singleton.h==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
class Log&lt;br /&gt;
{&lt;br /&gt;
  public:&lt;br /&gt;
    static Log&amp;amp; Instance(); //provide static member function to access the unique instance.&lt;br /&gt;
    &lt;br /&gt;
    double val;&lt;br /&gt;
  &lt;br /&gt;
  private:&lt;br /&gt;
    Log(){}; //prevent construction from outside this class' methods&lt;br /&gt;
    Log&amp;amp; operator=(const Log&amp;amp;); //prevent assignment&lt;br /&gt;
    Log(const Log&amp;amp;); //prevent copy construction&lt;br /&gt;
    &lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Singleton.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Log&amp;amp; Log::Instance() {&lt;br /&gt;
  static Log instance; //create as a static object, i.e. will only be created once.&lt;br /&gt;
  return instance;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Main.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;quot;Singleton.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
  Log::Instance().val = 2.0;&lt;br /&gt;
  &lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;val = &amp;quot; &amp;lt;&amp;lt; Log::Instance().val &amp;lt;&amp;lt; std::endl;;&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP/Classes/DownCasting</id>
		<title>CPP/Classes/DownCasting</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP/Classes/DownCasting"/>
				<updated>2010-11-24T02:14:07Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: /* DownCasting.cpp */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==DownCasting.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
class Base {&lt;br /&gt;
  public:&lt;br /&gt;
    virtual ~Base() { }; //at least one virtual function is necessary in the base class.&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class Derived1 : public Base {&lt;br /&gt;
  public:&lt;br /&gt;
    Derived1() { };&lt;br /&gt;
    ~Derived1() { }; &lt;br /&gt;
    void print(); //notice that print does not exist in Base.&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class Derived2 : public Base {&lt;br /&gt;
  public:&lt;br /&gt;
    Derived2() { };&lt;br /&gt;
    ~Derived2() { };&lt;br /&gt;
    void print(); //notice that print does not exist in Base.&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
  Base* ptr1 = new Derived1();&lt;br /&gt;
  Base* ptr2 = new Derived2();&lt;br /&gt;
&lt;br /&gt;
  //now we can try a dynamic down cast:&lt;br /&gt;
  Derived1* ptr3 = dynamic_cast&amp;lt;Derived1*&amp;gt;(ptr1);&lt;br /&gt;
  //if successful, ptr3 will be non-NULL:&lt;br /&gt;
  if(ptr3)&lt;br /&gt;
    ptr3-&amp;gt;print();&lt;br /&gt;
  else&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Could not down-cast ptr1 to Derived1 class!&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  &lt;br /&gt;
  //if we try with ptr2 it will not work because ptr2 is pointing to an object of class Derived2.&lt;br /&gt;
  Derived1* ptr4 = dynamic_cast&amp;lt;Derived1*&amp;gt;(ptr2);&lt;br /&gt;
  //if successful, ptr4 will be non-NULL:&lt;br /&gt;
  if(ptr4)&lt;br /&gt;
    ptr4-&amp;gt;print();&lt;br /&gt;
  else&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Could not down-cast ptr2 to Derived1 class!&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
&lt;br /&gt;
  delete ptr1;&lt;br /&gt;
  delete ptr2;&lt;br /&gt;
  //DO NOT DELETE ptr3 or ptr4 because they point to the same objects as ptr1 and ptr2, i.e., casting does not copy the pointed-to objects.&lt;br /&gt;
  return 0;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
void Derived1::print() {&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;Down cast to Derived1 was successful!&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
void Derived2::print() {&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;Down cast to Derived2 was successful!&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP/Classes/DownCasting</id>
		<title>CPP/Classes/DownCasting</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP/Classes/DownCasting"/>
				<updated>2010-11-24T02:13:22Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: /* Threads.cpp */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Threads.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
class Base {&lt;br /&gt;
  public:&lt;br /&gt;
    virtual ~Base() { }; //at least one virtual function is necessary in the base class.&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class Derived1 : public Base {&lt;br /&gt;
  public:&lt;br /&gt;
    Derived1() { };&lt;br /&gt;
    ~Derived1() { }; &lt;br /&gt;
    void print(); //notice that print does not exist in Base.&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class Derived2 : public Base {&lt;br /&gt;
  public:&lt;br /&gt;
    Derived2() { };&lt;br /&gt;
    ~Derived2() { };&lt;br /&gt;
    void print(); //notice that print does not exist in Base.&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
  Base* ptr1 = new Derived1();&lt;br /&gt;
  Base* ptr2 = new Derived2();&lt;br /&gt;
&lt;br /&gt;
  //now we can try a dynamic down cast:&lt;br /&gt;
  Derived1* ptr3 = dynamic_cast&amp;lt;Derived1*&amp;gt;(ptr1);&lt;br /&gt;
  //if successful, ptr3 will be non-NULL:&lt;br /&gt;
  if(ptr3)&lt;br /&gt;
    ptr3-&amp;gt;print();&lt;br /&gt;
  else&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Could not down-cast ptr1 to Derived1 class!&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  &lt;br /&gt;
  //if we try with ptr2 it will not work because ptr2 is pointing to an object of class Derived2.&lt;br /&gt;
  Derived1* ptr4 = dynamic_cast&amp;lt;Derived1*&amp;gt;(ptr2);&lt;br /&gt;
  //if successful, ptr4 will be non-NULL:&lt;br /&gt;
  if(ptr4)&lt;br /&gt;
    ptr4-&amp;gt;print();&lt;br /&gt;
  else&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Could not down-cast ptr2 to Derived1 class!&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
&lt;br /&gt;
  delete ptr1;&lt;br /&gt;
  delete ptr2;&lt;br /&gt;
  //DO NOT DELETE ptr3 or ptr4 because they point to the same objects as ptr1 and ptr2, i.e., casting does not copy the pointed-to objects.&lt;br /&gt;
  return 0;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
void Derived1::print() {&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;Down cast to Derived1 was successful!&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
void Derived2::print() {&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;Down cast to Derived2 was successful!&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP/Classes/DownCasting</id>
		<title>CPP/Classes/DownCasting</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP/Classes/DownCasting"/>
				<updated>2010-11-24T02:11:30Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: DownCasting.cpp&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Threads.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
class Base {&lt;br /&gt;
  public:&lt;br /&gt;
    virtual ~Base() { }; //at least one virtual function is necessary in the base class.&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class Derived1 : public Base {&lt;br /&gt;
  public:&lt;br /&gt;
    Derived1() { };&lt;br /&gt;
    ~Derived1() { }; &lt;br /&gt;
    void print(); //notice that print does not exist in Base.&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class Derived2 : public Base {&lt;br /&gt;
  public:&lt;br /&gt;
    Derived2() { };&lt;br /&gt;
    ~Derived2() { };&lt;br /&gt;
    void print(); //notice that print does not exist in Base.&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
  Base* ptr1 = new Derived1();&lt;br /&gt;
  Base* ptr2 = new Derived2();&lt;br /&gt;
&lt;br /&gt;
  //now we can try a dynamic down cast:&lt;br /&gt;
  Derived1* ptr3 = dynamic_cast&amp;lt;Derived1*&amp;gt;(ptr1);&lt;br /&gt;
  //if successful, ptr3 will be non-NULL:&lt;br /&gt;
  if(ptr3)&lt;br /&gt;
    ptr3-&amp;gt;print();&lt;br /&gt;
  else&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Could not down-cast ptr1 to Derived1 class!&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  &lt;br /&gt;
  //if we try with ptr2 it will not work because ptr2 is pointing to an object of class Derived2.&lt;br /&gt;
  Derived1* ptr4 = dynamic_cast&amp;lt;Derived1*&amp;gt;(ptr2);&lt;br /&gt;
  //if successful, ptr4 will be non-NULL:&lt;br /&gt;
  if(ptr4)&lt;br /&gt;
    ptr4-&amp;gt;print();&lt;br /&gt;
  else&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Could not down-cast ptr2 to Derived1 class!&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
void Derived1::print() {&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;Down cast to Derived1 was successful!&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
void Derived2::print() {&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;Down cast to Derived2 was successful!&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP/Boost/Threads</id>
		<title>CPP/Boost/Threads</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP/Boost/Threads"/>
				<updated>2010-11-24T01:55:04Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: /* Threads.cpp */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Threads.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;cstdlib&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;cmath&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/thread.hpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
void LongFunction();&lt;br /&gt;
		&lt;br /&gt;
int main(int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;Main: Before thread call&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  &lt;br /&gt;
  boost::thread MyThread(&amp;amp;LongFunction);&lt;br /&gt;
  &lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;Main: After thread call&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  &lt;br /&gt;
  MyThread.join();&lt;br /&gt;
  &lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void LongFunction()&lt;br /&gt;
{&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;Start LongFunction&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  unsigned int BigNum = 1e7;&lt;br /&gt;
  &lt;br /&gt;
  double temp;&lt;br /&gt;
  for(unsigned int i = 1; i &amp;lt; BigNum; i++)&lt;br /&gt;
  {&lt;br /&gt;
    temp = sin(i) / i;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;\r&amp;quot; &amp;lt;&amp;lt; std::setw(10) &amp;lt;&amp;lt; i &amp;lt;&amp;lt; setw(10) &amp;lt;&amp;lt; temp;&lt;br /&gt;
    std::cout.flush();&lt;br /&gt;
  }&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;End LongFunction&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP/Boost/Threads</id>
		<title>CPP/Boost/Threads</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP/Boost/Threads"/>
				<updated>2010-11-24T01:48:53Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: /* Threads.cpp */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Threads.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;cstdlib&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;cmath&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/thread.hpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
void LongFunction();&lt;br /&gt;
		&lt;br /&gt;
int main(int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;Main: Before thread call&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  &lt;br /&gt;
  boost::thread MyThread(&amp;amp;LongFunction);&lt;br /&gt;
  &lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;Main: After thread call&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  &lt;br /&gt;
  MyThread.join();&lt;br /&gt;
  &lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void LongFunction()&lt;br /&gt;
{&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;Start LongFunction&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  unsigned int BigNum = 1e7;&lt;br /&gt;
  &lt;br /&gt;
  double temp;&lt;br /&gt;
  for(unsigned int i = 1; i &amp;lt; BigNum; i++)&lt;br /&gt;
  {&lt;br /&gt;
    temp = sin(i) / i;&lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;\r&amp;quot; &amp;lt;&amp;lt; setw(10) &amp;lt;&amp;lt; i &amp;lt;&amp;lt; setw(10) &amp;lt;&amp;lt; temp;&lt;br /&gt;
    cout.flush();&lt;br /&gt;
  }&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;End LongFunction&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP/Boost/ThreadsMember</id>
		<title>CPP/Boost/ThreadsMember</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP/Boost/ThreadsMember"/>
				<updated>2010-11-24T01:48:00Z</updated>
		
		<summary type="html">&lt;p&gt;Mikael.s.persson: /* ThreadsMember.cxx */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==ThreadsMember.cxx==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;cstdlib&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;cmath&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/thread.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/bind.hpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
class Test&lt;br /&gt;
{&lt;br /&gt;
	public:&lt;br /&gt;
	void LongFunction();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
	Test MyTest;&lt;br /&gt;
	boost::thread MyThread(boost::bind(&amp;amp;Test::LongFunction, MyTest));&lt;br /&gt;
&lt;br /&gt;
	cout &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; &amp;quot;Stuff in main&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&lt;br /&gt;
	MyThread.join();&lt;br /&gt;
&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Test::LongFunction()&lt;br /&gt;
{&lt;br /&gt;
	cout &amp;lt;&amp;lt; &amp;quot;Start LongFunction&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
	unsigned int BigNum = 1e7;&lt;br /&gt;
&lt;br /&gt;
	double temp;&lt;br /&gt;
	for(unsigned int i = 1; i &amp;lt; BigNum; i++)&lt;br /&gt;
	{&lt;br /&gt;
		temp = sin(i) / i;&lt;br /&gt;
		cout &amp;lt;&amp;lt; &amp;quot;\r&amp;quot; &amp;lt;&amp;lt; setw(10) &amp;lt;&amp;lt; i &amp;lt;&amp;lt; setw(10) &amp;lt;&amp;lt; temp;&lt;br /&gt;
		cout.flush();&lt;br /&gt;
	}&lt;br /&gt;
	cout &amp;lt;&amp;lt; &amp;quot;End LongFunction&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==CMakeLists.txt==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
cmake_minimum_required(VERSION 2.6)&lt;br /&gt;
&lt;br /&gt;
Project(BoostThreads)&lt;br /&gt;
&lt;br /&gt;
ADD_EXECUTABLE(BoostThreadsMember BoostThreadsMember.cpp)&lt;br /&gt;
TARGET_LINK_LIBRARIES(BoostThreadsMember boost_thread-mt)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mikael.s.persson</name></author>	</entry>

	</feed>