I need to make a class Expr having public interface like this:
class Expr{
//...
public:
Expr(const char*);
int eval(); //Evaluates the expression and gives the result
void print();
};
In the design, if user enters an invalid string to construct an Expr object like "123++233+23/45", would it be right to construct the Object initially and notify the error when eval() is called on that object.
Or the error should be checked at that point itself and en exception be thrown, though that would lead to serious increase in runtime. And the user may write code furthur with assumption that Object is created and will discover the error at runtime only..
Such problems arise always in creating a class, is there a rather standard way to handle such errors made at user's part????