You'll have to return a CMatrix in some state that indicates failure, or if you want to complicate things you could return a pointer to a newly allocated CMatrix (in which case you could return NULL for a failure). Or you could throw an exception.