|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hello, I am new to C++ and I had a question I couldn't seem to find a
answer to. I want to see the source of cin, I am running Linux and I went into /usr/include and didn't find anything retaining to cin. Is there even a source file for cin? I would assume so since it's a function... Thanks for your time. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Oct 17, 3:39 pm, Americ...@gmail.com wrote:
> Hello, I am new to C++ and I had a question I couldn't seem to find a > answer to. I want to see the source of cin, I am running Linux and I > went into /usr/include and didn't find anything retaining to cin. Is > there even a source file for cin? I would assume so since it's a > function... > > Thanks for your time. The contents of istream class can be seen in <iostream> header. Its declaration can be found in <iostream> extern istream cin; The contents of class istream can be found in header <istream>. class istream is actually a typedef. typedef basic_istream<char> istream -N |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Oct 17, 3:49 pm, Neelesh Bodas <neelesh.bo...@gmail.com> wrote:
> On Oct 17, 3:39 pm, Americ...@gmail.com wrote: > > > Hello, I am new to C++ and I had a question I couldn't seem to find a > > answer to. I want to see the source of cin, I am running Linux and I > > went into /usr/include and didn't find anything retaining to cin. Is > > there even a source file for cin? I would assume so since it's a > > function... > > > Thanks for your time. > > The contents of istream class can be seen in <iostream> header. Its > declaration can be found in <iostream> > extern istream cin; Typo. Meant this - cin is an object of istream class. The declaration of cin can be found in <iostream> header. extern istream cin; -N |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
America01@gmail.com wrote:
> Hello, I am new to C++ and I had a question I couldn't seem to find a > answer to. I want to see the source of cin, I am running Linux and I > went into /usr/include and didn't find anything retaining to cin. Is > there even a source file for cin? I would assume so since it's a > function... If you want to use 'cin' as a programmer, you should not care much about it, 'cin' is just there. You should be aware that cin, being an istream-object, is just an interface that you can use to retrieve data. What the actual source of the data is, depends on how the executable/binary on your system had been launched (for example the user may have 'piped in' the contents of a file). Thus it is up to C++ run-time environment to provide you with the proper object behind 'cin' (which would be either a ifstream or some other stream that is tied to the console). This is all very platform dependent, and thus off-topic in this newsgroup. As a user of 'cin' you should write code that does not depend on which data source for 'cin' is actually used. Regards, Stuart |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On Oct 17, 6:39 am, Americ...@gmail.com wrote:
> Hello, I am new to C++ and I had a question I couldn't seem to find a > answer to. I want to see the source of cin, I am running Linux and I > went into /usr/include and didn't find anything retaining to cin. Is > there even a source file for cin? I would assume so since it's a > function... > > Thanks for your time. My debian install does have the source for iostream. It is located in / usr/include/c++/4.1.3/iostream According to dpkg this file was installed by the package libstdc+ +6-4.1-dev. You may need to install the libstdc++ development package for your distribution/compiler in order to mess with it. As previous posters have mentioned, this is strongly advised against. Any error you might see in istream is almost certainly the result of the misuse of an istream object and NOT a bug in the standard c++ library. If you are just curious what is in there, and you should be, then look here: http://gcc.gnu.org/onlinedocs/libstd...am-source.html and here http://gcc.gnu.org/onlinedocs/libstd...am-source.html YT, Dan Noland http://nolandda.org/ |
|
![]() |
| Outils de la discussion | |
|
|