[LC++]to throw or not to throw

Peter Poulsen peter_poulsen at stofanet.dk
Sat Apr 3 19:03:01 UTC 2004


Hi,

Two small classes:

class A {
        int method_one() throw() {
                return 10;
        }

        void method_two() throw(std::logic_error) {
                if(10 < 100)
                        throw logic_error("ups");
        };
};

class B {
        int method_one() {
                return 10;
        }

        void method_two()  {
                if(10 < 100)
                        throw logic_error("ups");
        };
};

The only difference between the two classes is that A tells which
exceptions it may throw.

I would like to know if people usually tries to tell which exceptions
their methods may throw, and if they explicitly tells if their method
doesn't throw a method at all (like A::method_two).


-- 
Yours 
Peter Poulsen




More information about the tuxCPProgramming mailing list