0

In the following program:

#include <iostream>
using namespace std;
void CleanCity(){
    try{
        throw "Garbage";
    }
    catch(const char *){
        cout << "Throw in Dustbin";
        throw;
    }
}
int main(){
    cout << "CleanCity mission starts";
    try{
        CleanCity();
    }
    catch(const char *){
        cout << "City Cleaned";
    }
    cout << "Well Done";
    return 0;
}

Can someone tell what the line throw ; does and how does this code print "City Cleaned". I also observed that if I remove throw ; then the program does not print "City Cleaned", but I can't get the reasoning behind it.

0 Answers0