* throw()...Clarification
@ 2005-05-16 18:58 Anand Chug
0 siblings, 0 replies; only message in thread
From: Anand Chug @ 2005-05-16 18:58 UTC (permalink / raw)
To: linux-c-programming
Hi
void f();
means that any type of exception may be thrown from the function. If you say
void f() throw();
it means that no exceptions are thrown from a function
So suppose i write a code like this
#include<iostream>
using namespace std;
class A
{
public:
A(int x1,int y1):x(x1),y(y1){} ;
int calc () throw();
private:
int x,y;
};
int A::calc ()
{
int temp;
temp=x-y;
if(temp<0)
throw 0;
return temp;
}
int main()
{
A a(4,5);
try{
a.calc ();
}catch(...)
{
cout<<"Exception"<<endl;
}
return 0;
}
According to the definition of throw()
calc() function should not throw any exception.
But while executing the above code in am getting "Exception" as output..
Any ideas...???
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-05-16 18:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-16 18:58 throw()...Clarification Anand Chug
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).