Last night I spent 1 hour to debug. I was writing a program of Huffman\_coding. Part of my *wrong* code is blow:

```
class HTree
{
public:
    HTree* left;
    HTree* right;
    int weight;
    char ch;

    HTree(){left = right = NULL; ch = '\0'; weight = 0;}
    HTree(HTree* l, HTree* r, char c, int w){left = l; right = r; ch = c; weight = w;}
    ~HTree(){delete left; delete right;}
    bool ISleaf(){return !left && !right;}
};

```

And this is one piece of code in `HTree* BuildTree(int* frequency)`:

```
QTree.push(new HTree(NULL, NULL, frequency[i], (char)i));

```

As can be see, the order of these two parameters is inverse - `char c, int w` and `frequency[i], (char)i`. I didn't realize this little mistake at the beginning. The output is, of course, wrong. 

But my question is, why can it still compile? or why can it still run? Because the answer/cout is totally wrong. And according to the different types, I think it cannot compile successfully - `char != int`, am I right?

Can anyone tell me why does this happen? Does it automatically converse the `int` to `char` and `char` to `int`, and then it can compile and run, and got a wrong answer? 

Well, let me specify more clearly, my **main** question is not whether it can automatically converse or not, it's *why my answer is wrong* if the converse can automatically happen.

The wrong output:

[enter image description here](https://i.stack.imgur.com/YRzWF.png)
-------------------------------------------------------------------

The right output:
[![enter image description here](https://i.stack.imgur.com/O51kF.png)](https://i.stack.imgur.com/O51kF.png)

Thanks in advance!