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: 
In the first case you call the actual object is of Child class:

```
Parent* p = new Child(); // you new'ed Child class
p->Method(); // and a method of a Child class object is getting called

```

that's why Child::Method() is called. In the second case you copy the Child class object onto the Parent class object:

```
Parent p = *(new Child()); // you new'ed Child, then allocated a separate Parent object on stack and copied onto it
p.Method(); // now you have a Parent object and its method is called

```

and Parent::Method() is called.
In your first example you call Method through a pointer:

```
p->Method();

```

In this case 'p' is a pointer to a Parent, and C++ knows that Parent has a v-table, so it uses that to find the actual method to call, which in this case as you state is `Child::Method()` because when C++ finds the v-table, it finds the v-table of the 'new' Child instance.

In the second example you call Method on an instance:

```
p.Method();

```

In this case 'p' is an instance of Parent and C++ assumes that it knows that the exact type is indeed 'Parent' and so it calls `Parent::Method()` without going through any v-tables.

I've just checked this with VS2008 and the above is actually what happens and there's ***no slicing***, however, I think that slicing **does** occur, but you would only see it in the second case if you did:

```
Parent& q=p;
q.Method();

```

Then I see: **Parent::Method()** being printed. `q.Method()` must be a virtual call, but it can only find the v-table for Parent.