Q:

Type Cast and Exception Handling

In below mention code when I call "method" with float argument, it automatically cast to int and perform the necessary task. But when if I throw float type and the immediate catch expects int argument, it is not working? why? 
Another thing, if there is no catch statement with float then should it go to general catch and from there if I re-throw which catch will handle it?
int method(int i)
{
    return i--;
}
void main()
{
    try {
        cout<<method(3.14);
        throw string("4");
    }
    catch(string& s){
        try{
            cout << s;
            throw 2.2;
        }
        catch(int i)
            cout<<i;

        catch(...)
            throw;

        cout<<"s"+s;
    }
    catch(...)
        cout<<"all";
}

A:

The function call is resolved at compile time, where the compiler is able to check the types, find the closest match (overload resolution) and then do the appropriate conversion. No such things happen in runtime when an exception is propagated. The exception is caught by a catch that matches the type exactly, or one of the exception's unambiguous bases. In your case int simply does not match a double.
As with your second problem: your rethrow is not enclosed by a try block, so it is not caught by the last catch(...). The last catch(...) corresponds to the first try block.

