2015年2月5日 星期四

Different between const int * , int const * and int * const

* Question: 
What different between const int * , int const * , int * const ?

* Answer: 
  • int*                                                           - pointer to int
  • const int * == int const *                     - pointer to const int
  • int * const - const pointer to int
  • const int * const == int const * const - const pointer to const int

  • int **                       - pointer to pointer to int
  • int ** const             - a const pointer to a pointer to an int
  • int * const *           - a pointer to a const pointer to an int
  • int const **            - a pointer to a pointer to a const int
  • int * const * const - a const pointer to a const pointer to an int


* Reference: 

http://stackoverflow.com/questions/1143262/what-is-the-difference-between-const-int-const-int-const-int-const

2015年2月4日 星期三

Difference between std::thread and pthread

* Question: 

What are the differences between std::thread and pthread


* Answer: 
The std::thread library is implemented on top of pthreads in an environment supporting pthreads 
std::thread provides portability across different platforms like Windows, MacOS, and Linux, but may not be complete on all platforms yet.
The C++11 std::thread class unfortunately doesn't work reliably (yet) on every platform, even if C++11 seems available.

* Reference: 
http://stackoverflow.com/questions/13134186/c11-stdthreads-vs-posix-threads

2015年2月3日 星期二

Difference between size_t and std::size_t


* Question: 

What are the differences between size_t and std::size_t



* Answer: 
C's size_t and C++'s std::size_t are both same.
In C, it's defined in <stddef.h> and in C++, its defined in <cstddef> whose contents are the same 
as C header (see the quotation below). Its defined as unsigned integer type of the result of the 
sizeof operator.

* Reference: 
http://stackoverflow.com/questions/5813700/difference-between-size-t-and-stdsize-t