Throw 
Author Message
 Throw

Hi

Can someone explain to me why every methods in the _com_error object has the statement "throw" at their declaration level, for example:

inline _com_error& _com_error::operator=(const _com_error& that) throw()
{

Quote:
}

inline DWORD _com_error::HelpContext() const throw()
{
...

Quote:
}

inline WORD _com_error::WCode() const throw()
{
....

Quote:
}

What does exactly the "throw" do when a method is declared like that?  Is that the requirement for a class object written to be .. threw?  If I create an error object derived from the _com_error class object, do I have to put the throw on every function also?  And when do I have to use the "const throw" vs. just a "throw"?

Thanks in advance.



Wed, 18 Feb 2004 07:28:57 GMT  
 Throw
Hi, David!

I would recommend to read some C++ book, but anyway,
throw() in this case declares that the method doesn't throw any
exceptions during execution.

But keep in mind this is just a declaration and VC6 compiler
doesn't control actual method behavior (whether it throws any
exceptions or not) and even produces warnings.

Alexey Krasnoperov,
Brainbench MVP for Visual C++,
http://www.brainbench.com


Hi

Can someone explain to me why every methods in the _com_error object has the
statement "throw" at their declaration level, for example:

inline _com_error& _com_error::operator=(const _com_error& that) throw()
{

Quote:
}

inline DWORD _com_error::HelpContext() const throw()
{
...

Quote:
}

inline WORD _com_error::WCode() const throw()
{
....

Quote:
}

What does exactly the "throw" do when a method is declared like that?  Is
that the requirement for a class object written to be .. threw?  If I create
an error object derived from the _com_error class object, do I have to put
the throw on every function also?  And when do I have to use the "const
throw" vs. just a "throw"?

Thanks in advance.



Wed, 18 Feb 2004 08:43:55 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. throw() vs throw(...)

2. Q) What is the difference between throw XXX and throw XXX* ?

3. property throws Exception in visual designer!

4. Throwing Exceptions in Constructors

5. System.Drawing.SafeNativeMethods threw an exception

6. std::list.clear() throws exceptions in .NET 2003.

7. Function that only throws an exception

8. too many controls throw exception

9. OK to throw exception from constructor?

10. __raise throws exception

11. VC6/VC7 bug with ?: operator and throw expressions.

12. Behavior of throw() exception specification?

 

 
Powered by phpBB® Forum Software