Should I use exceptions for checking valid input?

  assert, c++, c++20

I am using gcc10.2, c++20.

I am studying c++ after 2 years of python.

In python we always did run-time check for input validity

def createRectangle(x, y, width, height): # just for example
    for v in [x, y, width, height]:
        if v < 0:
            raise ValueError("Cant be negative")
    # blahblahblah

How would I do such process in c++?

Source: Windows Questions C++

LEAVE A COMMENT