|
From: Rik H. <ri...@kd...> - 1999-12-10 12:31:54
|
#if Frank V. Castellucci
> Right, but doesn't the issue of what we implement as a default persistence
> come into play?
Yes, I'd say that there's nothing like streaming :)
Correct me if I'm wrong, but I tried to do something like this a while
back:
class Base {
...
stream & operator << (stream & str, const Base &)
{
str << someData;
return str;
}
};
class Derived : public Base
{
...
stream & operator << (stream & str, const Derived &)
{
Base::operator << (str, *this);
str << someMoreData;
return str;
}
};
This didn't seem to work. It seems you have to do it this way:
class Base {
...
void save(stream & str)
{
str << someData;
}
};
class Derived : public Base
{
...
void save(stream & str)
{
Base::save(str);
str << someMoreData;
}
};
I could have explained this in words but I couldn't work out which
ones ;)
What I'm trying to say is that you can't use operators << and >> in
a derived class and still stream the base, so you'd have to use
a method like save(stream &). That's the only niggle I have with
streaming. Apart from that it's very convenient.
By 'flatfile', are you suggesting that writing to a 'text' file is
an option ? If so, I don't know whether this is worth it, as if
you're using 16-bit Unicode then the file will just look like garbage
in most text editors, so there's no 'readability' advantage.
Did I miss the point ?
Cheers,
Rik
|