Question: can you explain me why:

```
int main (int argc, char * const argv[]) {
    Parent* p = new Child();
    p->Method();
    return 0;
}

```

prints "**Child::Method()**", and this:

```
int main (int argc, char * const argv[]) {
    Parent p = *(new Child());
    p.Method();
    return 0;
}

```

prints "**Parent::Method()**"?

Classes:

```
class Parent {
public:
    void virtual Method() {
        std::cout << "Parent::Method()";
    }
};

class Child : public Parent {
public:
    void Method() {
        std::cout << "Child::Method()";
    }
};

```

Thanks,
Etam.

Answer: 
Your second code *copies* a `Child` object into a `Parent` variable. By a process called *slicing* it loses all information specific to `Child` (i.e. all private fields partial to `Child`) and, as a consequence, all virtual method information associated with it.

Also, both your codes leak memory (but I guess you know this).

You can use references, though. E.g.:

```
Child c;
Parent& p = c;
p.Method(); // Prints "Child::Method"

```
Your first case is simple. An instance of Child is created and asigned to p. So calling p->Method() calls Child::Method().

In the second case, four things happen:

1. An instance of the Child class, identified by a compiler-assigned temporary variable, is created.
2. An instance of of the Parent class, identified by the variable p is created.
3. The copy constructor Parent::Parent(Parent&) is called when p is instantiated to copy the Parent 'slice' of the state of the Child instance to p. *Note that if you don't define this copy constructor then the compiler creates it for you*.
4. You call Method() on p, which is an instance of **Parent**.

Try explicitly defining the copy constructor and you'll see that it is called.

Your possible confusion is probably because the assignments (=) in the two examples do different things. In the first example its simply setting one **pointer** equal to another, and there is only one object. In the second there are no pointers, so you're assigning (slicing) **value**. This invokes the copy constructor, and you get **two** objects (a Child and a Parent). The fact that the compiler is creating an invisible temporary variable doesn't help in understanding whats going on. You might check-out [this](http://en.wikipedia.org/wiki/Copy_constructor) article on copy constructors.

This is an easy mistake to make if you're used to languages like Java or C# where basically everything is a reference (aka a pointer).

As others have said, polymorphism only works with pointers and references, and these are not used in your second example.