Question: The drawimage method is not working. Is there any error in this code?
html:

```
<body>
<div id="container">
        <canvas id="canvas" width="700" height="350"></canvas>
</div> 
</body>

```

javascript:

```
function init()
{
var canvas = document.getElementById('canvas');
var ctx    = canvas.getContext('2d');
var chop   = new Image();
chop.src   = "chopper.png";

ctx.drawImage(chop,10,10,200,200);
};

window.onload = function() {init()};

```

Answer: 
By design.

The `static_cast` conversion is not designed to convert between unrelated pointer types, for that you need to use `reinterpret_cast`. If you want to be explicit about the cast you are doing, then use the correct one. The C style cast will do a `reinterpret_cast` in this case.

You really need to research about the different cast operators, as the comment on `dynamic_cast` does not make much sense either.
As others have said, the solution is to use `reinterpret_cast`, which is meant to be used when casting between unrelated pointer types:

```
T* ptr = reinterpret_cast<T*>(_top);

```

If you use `placement new` instead, you not only avoid the casting problem but you also fix the problem of not calling the constructor for types that have a constructor:

```
T* ptr = new(_top) T();

```