Discussion: exception catch
Afficher un message
Vieux 08/12/2007, 12h04   #2
Ian Collins
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: exception catch

Rahul wrote:
> Hi Everyone,
>
> I have the following exception class,
>
> class E1
> {
> };
>
> class E2
> {
> public: E2(const E1&)
> {
> printf("automatic type conversion\n");
> }
> };
>
> int main()
> {
> try
> {
> throw E1();
> }
> catch(E2 obj)


Don't catch exceptions by value, use a const reference.

--
Ian Collins.
  Réponse avec citation
 
Page generated in 0,04245 seconds with 9 queries