| re: ifstream as parameter
"Gunnar" <gunix@comhem.se> wrote[color=blue][color=green][color=darkred]
> >> class ios : public _ios_fields {
> >> ios& operator=(ios&); /* Not allowed! */
> >> ios (const ios&); /* Not allowed! */
> >>
> >> What does this mean?[/color]
> > Streams are not copyable.[/color]
> Well, yes, it says so, but what is it that makes it uncopyable?
>
> How can I write my own class
> class Foo{
> int number;
> };
>
> and make it forbidden to copy?
>
> Foo& (const Foo&);
>
> seems ok to me, but perhaps I've just forgotten about CC's?[/color]
Make the copy constructor and assignment operator private (like in
the "ios" example - remember members are private by default if you
declare your class with "class"). If you write any constructors you
don't get the implicit default constructor, so make sure you write
at least one accessible constructor or you won't be able to create
any objects of this class.
Regards
Buster |