From: Anand Chug <anand.chug@gmail.com>
To: linux-c-programming@vger.kernel.org
Subject: throw()...Clarification
Date: Tue, 17 May 2005 00:28:48 +0530 [thread overview]
Message-ID: <ed9edacc05051611583f3cd958@mail.gmail.com> (raw)
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...???
reply other threads:[~2005-05-16 18:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ed9edacc05051611583f3cd958@mail.gmail.com \
--to=anand.chug@gmail.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).