Handling exceptions

Hello, I am reading a C++ book, and am in the section of handling exceptions. I am wondering why the exception handler, when handling strings, must use a pointer to a char? For example, look at the parameter list of the catch statement:

1
2
3
4
5
6
7
8
9
10
11
12
 try
 {
     quotient = divide(num1, num2);
     cout << "The quotient is " << quotient << endl;
 }
 catch (char *exceptionString)
 {
     cout << exceptionString;
 }

I received an error when I used: catch (char exceptionString)
Why?
Because type of thrown parameter must match catching type. So if you throw pointer to char array. you must catch pointer to char array.
what book are you reading?
Starting Out With C++: Early Objects 7/E by Tony Gaddis
okay thank you.
Topic archived. No new replies allowed.