Q:

Assign Derived class Constructor to Base class Pointer

I was trying to understand virtual functions, and came across the following code.
class Base
{
  public:
            void Method1 ()  {  std::cout << "Base::Method1" << std::endl;  }
    virtual void Method2 ()  {  std::cout << "Base::Method2" << std::endl;  }
};

class Derived : public Base
{
  public:
    void Method1 ()  {  std::cout << "Derived::Method1" << std::endl;  }
    void Method2 ()  {  std::cout << "Derived::Method2" << std::endl;  }
};

Base* obj = new Derived ();
  //  Note - constructed as Derived, but pointer stored as Base*

obj->Method1 ();  //  Prints "Base::Method1"
obj->Method2 ();  //  Prints "Derived::Method2"

Towards the end, how is a Base class pointer being initialized with derived class Constructor? 

A:

C++ allows an implicit cast from a derived pointer type to a base pointer type. This is safe because the memory layout of the derived type is the same as the base up to the size of the base class.
You example has a potential bug though, since you have lost track of the real type of obj. When it comes time to delete it, you will call the wrong destructor. This can be remedied by make the destructor virtual.

