Re: How to use the istream and ostream?
Ma Xiaoming wrote:
#include <iostream>
istream& operator>>( istream&, String& );
ostream& operator<<( ostream&, const String& );
class String;
class String {
[...]
bool operator==( const String& );
bool operator==( const char* );
const? Consider making those (friend) functions instead so you can overload
for const char* on the left side, too.
int size() { return _size; }
size_t? const?
char* c_str() { return _string; }
const?
[...]
When I include this header file in my project and compile the project
with VC++ 7.0 which was in Visual Studio .NET 2003, the two lines would
cause error:
istream& operator>>( istream&, String& );
ostream& operator<<( ostream&, const String& );
Just a suggestion for the future: remove everything else that is not needed
to demonstrate the problem. You have in fact two problems here:
- 'istream' and 'ostream' are not types, you mean 'std::istream'
and 'std::ostream'.
- 'String' is not a known type at that time. You could fix that by moving
the declaration ("class String;") to before these two lines.
Uli