2 ms·
Not at all, there are several other ways: - Error flag in the class (not a good solution, though, as others have noted) - Factory function that returns a smar
by iainmerrick 8y ago
Not at all, there are several other ways:
- Error flag in the class (not a good solution, though, as others have noted)
- Factory function that returns a smart pointer, or null on error.
- Just ensure your constructor never fails. (This probably means aborting on allocation failure. In practice that’s usually fine, depending on application.)