Is it good practice to use assert() in class mutators?

Posted by cactusbin on Stack Overflow See other posts from Stack Overflow or by cactusbin
Published on 2010-06-13T05:30:47Z Indexed on 2010/06/13 5:42 UTC
Read the original article Hit count: 213

Filed under:
|

For example:

void Date::month(unsigned int inMonth) {
    assert(inMonth <= 12);
    _month = inMonth;
}

If this is not good practice, what is the correct way to go about this?

© Stack Overflow or respective owner

Related posts about c++

Related posts about assert