Most suitable way for returning the logical errors

What is most suitable way for returning the logical errors in a C plus plus program?

  • Rahul
  • 02 अप्रैल
  • 1 उत्तर

1 उत्तर
1-1 of  1
1 Answer
  • The better way is to throw custom exception. That's why they were introduced. If you need to provide specific info, like ErrorCode or something else, you could easily extend base Exception class to do so. Main reasons are:

    You can ignore invalid error code returned from your funcion and this could lead you to the situation where your system state is corrupted whereas Exception is something you can't ignore.
    If your funcion does something usable then it should return some data you interested in and not the error codes, this gives you more solid design.....
    0

c plus plus programming
मॉक परीक्षण अभ्यास के लिए
c plus plus programming