EDIT Answered: Although my original question didn't explain my needs in exactly the way the answer provided by Konrad Rudolph addressed them, He (by accident or design) essentially wrote for me what I was trying to write! The class itself does not get extended, but has it's functionality extended by making the class aware of new functions which allow it (the class) to handle a wider array of issues. My grateful thanks for an excellent answer which in turn is also a great tutorial, even if it does require some ahemm light? reading of books by me ;-).
I am sure that this a very basic question, but I am trying to self teach C++, and the reference books which I am using are providing answers which I do not understand.
For my project I am defining a class error_handler {}
which processes exception messages and error numbers from the programs various points. It will log the error to a file and/or print the message to the screen using various member functions.
My goal is to create this so that it has it's own .h and .cpp files, and if I later need to extend it simply add a a new member function to handle some more obscure type of error manipulation.
My question then is this:
Since in error.h
I have the code:
class error_handler
{
// ctor dtor copy logger screen functions defined
}
And in error_handler.cpp
I complete those definitions,
How can I simply simply add a new function to the class? I do not wish to sub class it, simply extend it.
For a use case scenario assume that error_handler is a class defined in a proprietary package where I am not free to modify the source directly, but am allowed to extend it in separate code.
EDIT: Answers and comments thus far seem to indicate I am trying to do something the language isn't meant to do. If so then so be it, I have learned something here. In the hopes that this is not the case I will leave the question open for a bit to see what else might wander onto this post......