I have written a field class that inherits from the string class, but I need to overload the << and >> operators to handle input/output to a file but I am having trouble with the implementation.
Any help?
Printable View
I have written a field class that inherits from the string class, but I need to overload the << and >> operators to handle input/output to a file but I am having trouble with the implementation.
Any help?
Post what code you do have, and the errors you're getting.
In addition to posting code, maybe you can reassure us that you've considered the fact that is generally considered a bad idea to use a class that has no virtual destructor (or any other virtual functions) as a base class. In this case, string was not designed to be inherited from through public derivation.
If you have considered this, then okay, good luck. :)
If not, then maybe you should consider a different solution. Or if you are interested maybe I or someone else here can explain the dangers of doing that in more detail.
Yeah -- deriving from std::string == bad
Perhaps you can create a new typedef with different parameters to std::basic_string, and then overload the functions you need.