Anton Pervukhin wrote:[color=blue]
>[color=green]
> > Your class doesn't correctly handle copying, which would be disaterous with
> > an auto_ptr as member.[/color]
>
> why it should be disasterous with an auto_ptr as member?[/color]
because it has a wrong copy semantics. For the same reason auto_ptr
cannot be used in a container.
[color=blue]
> If I disable copy constructor and assignment operator, will it be still
> dangerous to use auto_ptr?[/color]
Then you are fine. But you didn't :-)
[color=blue]
>
>[color=green]
> > I'm wondering why you don't just add an _instance_ of std::ofstream as a
> > member.[/color]
>
> Good question ;-) I just decided to give a try to use auto_ptr, since
> the class is not going to be copied or assigned.[/color]
Thats not a good reason. Your first question should be: Do I need to allocate
dynamically or not. Only then, after you decided that you need dynamic allocation
you can ask the question if some smart pointer is the way to go.
But in your case, I really see no reason why the stream object has to be allocated
with new. Especially because you say you don't want to copy or assign such an object.
Whats wrong with using an ordinary ofstream member and open the file with open()?
--
Karl Heinz Buchegger
kbuchegg@gascad.at