title: Casting pointer from one base type to another
body: <p>-EDIT-</p>
  
  <p>Thanks for the quick response, I'd been having really weird problems with my code and I changed my casts to dynamic_cast and its working perfectly now</p>
  
  <p>-ORIGINAL POST-</p>
  
  <p>Is it safe to cast a pointer of one base class to another base class? To expand on this a bit, will the pointer I've marked in the following code not result in any undefined behavior?</p>
  
  <pre><code>class Base1
  {
  public:
     // Functions Here
  };
  
  
  class Base2
  {
  public:
     // Some other Functions here
  };
  
  class Derived: public Base1, public Base2
  {
  public:
    // Functions
  };
  
  int main()
  {
    Base1* pointer1 = new Derived();
    Base2* pointer2 = (Base2*)pointer1; // Will using this pointer result in any undefined behavior?
    return 1;
  }
  </code></pre>