class IErrorLog { public: virtual bool OpenLog(const char *strFilename) = 0; virtual bool CloseLog() = 0; virtual bool WriteError(const char *strErrorMessage) = 0; }; class FileErrorLog : public IErrorLog { bool OpenLog(const char *strFilename) { cout << strFilename <<" is opened in FileErrorLog"<<endl; return true; } bool CloseLog() { cout << "Close Log in FileErrorLog"<<endl; return true; } bool WriteError(const char *strErrorMessage) { cout << "Error: "<<strErrorMessage<<" in in FileErrorLog"<<endl; return true; } public: FileErrorLog(){} }; int main() { FileErrorLog *f1= new FileErrorLog; IErrorLog *ptr = new FileErrorLog; bool er=ptr->WriteError("Memory finished"); bool f=f1->WriteError("direct");
ptr
IErrorLog
IErroLog
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)