Forum
Resources
Mentors
Projects
Entrance Exams
Question Papers
Colleges
Courses
Universities
Make Money
Members
Bookmarks
Polls
Fresher Jobs
Funny Pictures
MCA Projects
New Member FAQ
My Profile
Sign In
Register
AdSense Revenue
Active Members
Today
newbie
(1023)
Adil Sharif ...
(615)
indian
(468)
Last 7 Days
bharath sudar
(4837)
S.Yamininagara...
(3449)
Adil Sharif ...
(3343)
more...
Awards & Gifts
Online Exams
Aptitude Questions
General Aptitude Tests
Medical Entrance
Engineering Entrance
Bank Tests
TOEFL & IELTS Questions
Fresher Jobs
Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi
Resources
Find educational articles, blogs, discussion threads and other resources.
Colleges
Find details about any college in India or search for courses.
Advertisements
Watch Asianet TV online
Kairali TV in Internet
Surya TV online
Amritha TV Channel
exception handling in c++ (divide by zero)
Posted Date: 15 Mar 2008 Resource Type:
Articles/Knowledge Sharing
Category:
Computer & Technology
Posted By:
ashish singh
Member Level:
Diamond
Rating:
Points
: 2
//program for exception handling
//exception handling in c++
#include
class number
{
private:
float num;
public:
void read()//read number from keyboard
{
cin>>num;
}
void show()//display number
{
cout<
}
class divide{};//abstract class used in exceptions
float div(number num2)
{
if(num2.num==0)
throw divide();//raise exception
else
return num/num2.num;
}
};
int main()
{
number num1,num2;
float result;
cout<<"enter number 1:";
num1.read();
cout<<"enter number 2:";
num2.read();
try
{
cout<<"trying division operation....";
result=num1.div(num2);
cout<<"succeeded"<
}
catch(number::divide )
{
cout<<"failed"<
cout<<"exception:divide-by-zero"<
return 1;
}
num1.show();
cout<<"/";
num2.show();
cout<<"="<
return 0;
}
Responses
No responses found. Be the first to respond and make money from
revenue sharing program
.
Feedbacks
Popular Tags
What are tags ?
Search Tags
Sign In
(No tags found.)
Post Feedback
This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must
Sign In
to post a response.
Next Resource:
C++ Program showing dynamic memory allocation
Previous Resource:
C++ program to calculate exponential
Return to Discussion Resource Index
Post New Resource
Category:
Computer & Technology
Post resources and
earn money
!
Related Resources
//C++ program for newton backward interpolation formula
C program to find the greatest of 5 nos
Holographic Memory
Digital Subscriber Line DSL
Destructors in C++
Contact Us
Privacy Policy
Terms Of Use
SpiderWorks Technologies Pvt Ltd. 2006 - 2007 All Rights Reserved.