C++ Exception and Invariant

11 views
Skip to first unread message

Zorro

unread,
May 10, 2024, 6:47:42 PM5/10/24
to computer.lang.Z++
C++ exception is just a hack. You can only catch an exception explicitly thrown in your code. That is, C++ exception mechanism cannot catch exceptions raised implicitly by your code.

An invariant, on the other hand, is a boolean statement as part of the definition of a class. Once the invocation of a method of class violates the invariant, the compiler implicitly raises the exception associated with the invariant. C++ exception cannot catch such an exception.

Z++ classes/tasks can specify any number of invariant statements, each with its own exception to be raised.

In addition, methods of a class can specify constraints, each with its own exception to be raised.

C++ is just a subset of Z++. Furthermore, Z++ is platform independent and component oriented.

For Z++ visit www.ZHMicro.com



Reply all
Reply to author
Forward
0 new messages