I have a function with the following header:
std::vector<NxU32> MySewer::createCuttingArray(MyCloth** cloth, NxU32 startPoint, NxU32 endPoint)
The function is supposed to return a vector containing some integer values. But there is one problem: If the line is not correctly created (there is a way in which this can happen), I want to do something like what I did in Java and C#, to return a NULL. But from what I see, in C++, NULL is defined as an integer value. How can I return a valid NULL for a vector?
The "correct" way to deal with this really depends on what the code receiving the vector actually does. Is it cause for an error, or simply "we ignore this"?
If it's an error, use throw some_exception_goes_here;
, because that is much easier than going down the line with a NULL value.
If you want to just ignore it, return an empty vector and then make sure the code below isn't going to have problems with an empty vector.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With