T
Tony Johansson
Hello!
I'm reading in a book about C++ and there is something that I want to ask
you about.
It says "since the constructor does not return any value, the only way to
handle errors that
occur during its execution is to use exception handling. You can deal with
errors
that occur during the execution of the constructor's body by using try block
within this body. The constructor can catch exception thrown by other
constructors invoked from the member initialization list."
I understand the text but not the bit of code below. Why having a try block
here
This bit of code is from the book. There can't exist any exception within
the try block
void Student::Student(long number, string name)
try
: number_(number), name_(name){
}
catch exc& e){
.....
}
//Tony
I'm reading in a book about C++ and there is something that I want to ask
you about.
It says "since the constructor does not return any value, the only way to
handle errors that
occur during its execution is to use exception handling. You can deal with
errors
that occur during the execution of the constructor's body by using try block
within this body. The constructor can catch exception thrown by other
constructors invoked from the member initialization list."
I understand the text but not the bit of code below. Why having a try block
here
This bit of code is from the book. There can't exist any exception within
the try block
void Student::Student(long number, string name)
try
: number_(number), name_(name){
}
catch exc& e){
.....
}
//Tony