extending c++ classes and enumerations
Hi!
I have some question about a C++ syntax that can extend classes and
enumerations. A modern language should support this. :-) I'm asking
because there seems to be a dozen c++ entusiasts reading this group,
and I guess this is the right place to go, perhaps resulting in finding
support, new friends or whatever. :-)
To put myself shortly,
* extending instance member fields (autos and volatiles) and instance
functions (virtuals) would be an error.
* Extending static functions and fields and non-virtual functions
would be legatime.
* Extending enumeration automatically starts the increment from the
previously enumeration definition.
Has this been discussed before? Has anyone other thought about this? If
you have, you are welcome to exchange ideas with me. ;-)
In practice, this kind of statement is what I'm thinking about.
// File string+more.h
#include <string>
namespace std
{
extend // extends class basic_string
template<typename _CharT, typename _Traits, typename _Alloc>
class basic_string {
public:
int stringEncoding; // Error
static int defaultCStringEncoding; // OK
static int defaultCStringEncoding(); // OK
bool hasPrefix(const basic_string& s); // OK
virtual basic_string& description(); // Error
};
}
// File enum.h
enum ThreadState { ERROR = -1, RUNNING, TERMINATED };
extend enum ThreadState { CANCELED };
Thanks in advance.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]