Rabu, 01 Maret 2017

How to throw Exceptions in Function Definition C++ Programming

A function can declare what type of exceptions it might throw. Syntax for declaring the exceptions that a function throws is as follows: 1 2 3 4 5 return–type function–name(params–list) throw(type1, type2, ...) { //Function body ... }   Following program demonstrates throwing exceptions in a function definition: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 #include<iostream> using namespace std; void sum() throw(int) { int a, b; cout<<“Enter a and b values: “; cin>>a>>b; if(a==0 || b==0) throw 1;

The post How to throw Exceptions in Function Definition C++ Programming appeared first on Coding Security.


How to throw Exceptions in Function Definition C++ Programming
read more

Tidak ada komentar:

Posting Komentar