How to handle the exception in C++?
Answer:
An exception is a problem that arises during the execution of a program. One of the advantages of C++ over C is Exception Handling.
C++ provides the following specialized keywords to handle the exception,
try: A try represents a block of code that can throw an exception.
catch: A catch represents a block of code that is executed when a particular exception is thrown.
throw:The throw keyword is used to throw an exception. Also used to list the exceptions that a function throws, but doesn’t handle itself.
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Answer:
An exception is a problem that arises during the execution of a program. One of the advantages of C++ over C is Exception Handling.
C++ provides the following specialized keywords to handle the exception,
try: A try represents a block of code that can throw an exception.
catch: A catch represents a block of code that is executed when a particular exception is thrown.
throw:The throw keyword is used to throw an exception. Also used to list the exceptions that a function throws, but doesn’t handle itself.
need an explanation for this answer? contact us directly to get an explanation for this answer