It is impossible to stop the creation of an object without metalization. The best thing you can do is set the flag "invalid parameter", which you should check later, and if true, discard the object without using it.
With the requirements that you have, it would be better to use the factory method to create objects - this way you can do the checks before calling the constructor:
class item
{
int i;
public:
static item* create(int no) {
if (no < 0) {
return 0;
}
return new item(no);
}
private:
item(int no) {
}
};
You can use this as
item* myItem = item::create(-5);
if(!myItem) {
}
item .