Suppose I have a class that process some data
class SomeClass
{
public:
void SetData(IData*);
void ProcessData(void);
}
The class would need the data to be set before ProcessData() can be called. What are some ways to enforce this dependency? I could return an error code or throw an exception if ProcessData() is called before any data has been passed in. How sound is it to throw an exception?
Additional information Some of the answers suggest passing in the IData to the constructor or ProcessData(). Those are sound answers. The reason why I am not doing this because this part of a GUI system. The user may load in new data to SomeClass any point in time and make modification to it, so during the time when SomeClass is created, the data may not be available.
(Yes, there are better design I could use to avoid this problem, but boss wants to see results on the screen and I have to compromise between good design and visual results).