I know that in JAVA, the exception is passed through class objects.

In C ++, it is possible to transfer not only class objects, which, it seems to me, is not always competent from a programming point of view.

Can you please provide some more or less real, competent example of passing an exception in C ++?

  • @ usk-dima, sure that you really want to use exceptions ? - avp
  • @avp, in my opinion, the reasons for not using exceptions from the article you cited are, if not contrived, then at least hardly able to outweigh the benefits of using them. - DreamChild
  • @DreamChild, in fact, the real problem lies deeper , and maybe even deeper . But, as strange as it may seem, in practice this situation suits everyone ... - avp
  • 2
    @avp, @DreamChild: It seems to me that the problem of both exceptions and the object-oriented approach (these things seem unrelated to me) is this: people consider them to be something more than they really are. OOP does not eliminate the need to think and build abstractions correctly. Classes are not an end in themselves, but only an assistant to achieve encapsulation (which in principle can be achieved by other methods). If the programmer does not realize the need for encapsulation, it is too early for him to use classes (or another tool). Thoughtless use of powerful tools may well make the code worse. - VladD
  • 3
    ... Exceptions are not a method that eliminates the need to think about errors, but the code that allows you to transfer an error along the stack with its auto-roll. They also do not negate the need to think, to adhere to certain principles in programming (the same principle “computation, then commit”, for example) and to understand what exactly happens in the code. In short, the devastation as usual in the heads. - VladD

0