Conversation started Sep 11, 2012 at 2:39.
Sep 11, 2012 02:39
What is the differnce between passing a filestream object by reference to a function and---- passing the actual filestream object( ie. copying its contents?
@MohamedAhmedNabil Simple: passing by reference works. Passing by value doesn't (iostreams aren't copyable).
Those modem bleepings ... BBS Wonderland ... so magical
@JerryCoffin The stream itself isnt copyable, but what is stored in the filestream is?
If modify the filestream by reference you are canching the actual reference content
@LeandroPezzente But just copying it will cause to open the same file.
Sep 11, 2012 02:42
@MohamedAhmedNabil There are a few bits and pieces that could probably be copied in isolation, but for the most part you don't worry about it. It's a pretty simple rule: you always pass them by reference. The only (rather rare) exception is to pass a pointer instead, used primarily if you really need to be able to pass a null pointer.
No because you will be modifying a copy in momery of the actual file
*memory
@MohamedAhmedNabil Passing it by value is a compile-time error.
Really ?
Didnt knew that.
Yeah it's a compiler error.
@EtiennedeMartel Why? (and please dont say because the standard says so)
Sep 11, 2012 02:46
Copy constructor of ios_base is private. Since all stream classes inherit from that, they cannot be copied.
That's why we say streams are non copyable: they don't have a public copy constructor.
 
Conversation ended Sep 11, 2012 at 2:47.