title: Why can I cast pointers of unrelated classes without error?
body: <p>I've been experimenting with pointers and written the following code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using std::cout;
  
  struct A
  {
      int a;
      char b;
      A(){ a = 4; }
  };
  
  struct B
  {
      int c;
      B(){ c = 5; }
  };
  
  A *a = new A;
  B *b = new B;
  
  int main()
  { 
      a = (A*)b; 
      cout &lt;&lt; a -&gt; a; //5
  }
  </code></pre>
  
  <p>Why <code>B*</code> can be converted to <code>A*</code>? Can any pointer be converted to any other pointer?</p>