Sponsored link Serve your customers, not your servers, with VERIO Linux VPS. Full-access test-drive here. |
c++ vs cc++ vs cPosted Mar 27, 2008 14:51 UTC (Thu) by jimparis (subscriber, #38647)In reply to: yet another +5 by pr1268 Parent article: Striking gold in binutils
> C++
>
> int x;
> ifstream in_file;
> in_file.open("foo.txt");
> assert(in_file);
> in_file >> x;
> C
>
> int x;
> FILE* in_file;
> in_file = fopen("foo.txt", "r");
> assert(in_file);
> fscanf(in_file, "%d", &x)
Here's something that really bugs me about C++. Where's the documentation? With C, "man
fopen" "man assert" "man fscanf" gives me all the info I need. With C++, I suppose some
manual page for ifstream would be most appropriate, but I don't seem to have it. Which
package is that in? Or must I resort to google searches every time?
Of course, even if I did have C++ manpages, deciphering "in_file >> x" still requires that I
track backwards to figure out the types of "in_file" and/or "x" (yay operator overloading!)
(Log in to post comments)
c++ vs c Posted Mar 27, 2008 15:13 UTC (Thu) by pr1268 (subscriber, #24648) [Link] I suppose some manual page for ifstream would be most appropriate, but I don't seem to have it. All Glibc standard library functions have man pages (I'm unsure whether these came before or after the shell functions' man pages). I think this might be related to the founding philosophy that C is supposed to be portable, and the man pages were a convenient way of distributing documentation on the system call interfaces without having to decipher C code you've never seen before (not impossible, but time-consuming). I can't recall ever seeing a C++ man page, but then again, the whole language standard was in limbo up until its 1998 ISO standardization. Not sure why they don't exist nowadays, but perhaps Stroustrup would prefer that you buy his book instead (stupid conspiracy theory). Some of the top links in Google searches for various C++ functions and standard library classes are quite decent (IMO). Personally, I recommend anyone trying to "dive into" C++ go find a used C++ textbook. Just be sure to get one dated more recent than 1998 (because older C++ texts are rife with code that predates the ISO standard).
c++ man pages on gcc.gnu.org Posted Mar 27, 2008 17:01 UTC (Thu) by bkoz (subscriber, #4027) [Link] See: http://gcc-ca.internet.bs/libstdc++/doxygen/ I believe some os vendors (debian, I think) package these. -benjamin
c++ vs c Posted Mar 28, 2008 12:00 UTC (Fri) by cortana (subscriber, #24596) [Link] Indeed, man pages are not really suitable for C++ (and many other languages) for the reasons you state. If you are on a Debian system, run: apt-cache -n search libstdc++ doc and install one of those packages. Then check out its directory in /usr/share/doc. The docs are also online at http://gcc.gnu.org/onlinedocs/libstdc++/. A very nice quick reference to iostreams and the STL can be found at http://cppreference.com/. I have to say I don't really prefer the man pages for C development because often they contain oudated or just plain incorrect information. I prefer to use the glibc manual directly for reference.
|
Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds
Powered by Rackspace Managed Hosting.