title: Does typedef in C/C++ really create a NEW type by combining the compound type (e.g. int*)?
body: <p>recently I found <code>typedef</code> in my code works really different than what I proposed. An example like this:</p>
  
  <pre><code>typedef int *ptype;
  ptype v1 = 0, v2 = 0;
  </code></pre>
  
  <p>The result: both v1 and v2 were defined as a pointer to <code>int</code> type. But if you simply replace <code>ptype</code> by <code>int *</code> in the second sentence as <code>int *v1 = 0, v2 = 0;</code> or <code>int* v1 = 0, v2 =0;</code>, only v1 will be the pointer and v2 is normal <code>int</code>. It seems <code>typedef</code> does not do a simple replacement. What's more, when it comes to complicate modifier like:</p>
  
  <pre><code>typedef int *ptype;
  const ptype v3 = 0;
  </code></pre>
  
  <p>The result will be: v3 is a <code>const</code> pointer, not a pointer to the <code>const</code> int if we write <code>const int *v3 = 0;</code>. In the above code <code>const</code> stands as the modifier to the whole <code>ptype</code>, not the <code>int</code> inside <code>ptype</code>. Thus it really looks like <code>typedef</code> combines the compound type <code>int*</code> and creates a new type.</p>
  
  <p>However, the authoritative C/C++ reference website <a href="http://www.cplusplus.com/doc/tutorial/other_data_types/" rel="noreferrer">cplusplus</a> says "typedef does not create different types. It only creates synonyms of existing types." so I was really confused and hope someone can help explain the behavior of <code>typedef</code>. Thanks!</p>