I'm a novice programmer who just migrated from Python (on IDLE) to C++ and I'm finding it uncomfortable to know only a few "essential" methods of STL data structures. Is there something like the Python help() function in C++, or some other way to access digestible and concise documentation as regards the Standard Library?
Edit: To be clear, I am looking for a way to access documentation from my computer, preferably from within the IDE/compiler (I currently use and prefer g++ on Cygwin in Windows 7. I also have Code::Blocks, however). Please don't recommend books or mark this question as a duplicate of The Definitive C++ Book Guide and List.
This is the documentation I like the most : http://en.cppreference.com/w/
With a keyword for fast searching in Firefox, it is very efficient
In general Cplusplus.com helps very much.
Maybe the GNU C++
Library will also help.
You could also read the official C++
book by Bjarne Stroustrup.
http://cppreference.com
http://www.cplusplus.com
If you're on Mac OS, you can use the nice Dash which can integrate with editors or be used on its own. It supports the cppreference.com docs (instant offline indexed documentation).
If you're on Windows (Visual Studio) MSDN also provides STL docs.
As I'm on Linux I just use http://cppreference.com, but I'd like to have a good alternative (not Zeal) to Dash.
Related
I just started to get my hands dirty with C/C++, and I am still getting my head around the different concepts (I've written mostly Java previously). I'd really like to know which C/C++ compiler is used and also which standard library is included. Also, I'd like to know where I can find the API documentation of the respective standard library (like the Java SE API docs).
For C++:
Xcode 4.6.2 uses the Clang C++ compiler frontend with LLVM as backend which is conform to the C++11 standart and uses libc++ as the standart library.
Here you can finde a apple presentation about libc++.
I'm not an XCode user, but it seems to be Apple's LLVM Compiler (by default) according to Apple's website: https://developer.apple.com/technologies/tools/. But, I guess, like any other IDE XCode does support other compilers like GCC. Also depends on your XCode version it seems: http://useyourloaf.com/blog/2011/03/21/compiler-options-in-xcode-gcc-or-llvm.html
Here's a question in SO that asks about the default compiler and the answer seems to have the code to find just that: In Xcode 4.5, what is "Compiler Default" for "C++ Standard Library" and "C++ Language Dialect"?
According to this post 4.6 uses clang instead of GCC for C++: http://cplusplusmusings.wordpress.com/2013/02/26/c-and-xcode-4-6/
P.S.: Googling does help ;)
I just noticed the second half of the question was never really answered:
... I'd like to know where I can find the API documentation of the
respective standard library ...
A simple Google search will reveal a wealth of information about this. Do note, however, that the "C++ Standard Library" is not the same thing as the "C Standard Library," so be careful of that when searching and reading. C++ has its roots in C, but the two have diverged to become separate languages that share a lot of commonality -- and a lot of hidden differences.
The canonical reference work regarding this is titled, appropriately enough, "The C++ Standard Library" by Nicolai M. Josuttis, published by Addison-Wesley. Many C++ programmers keep this on their bookshelves as a reference.
There is a good online reference for the library at https://cppreference.com/.
If you are interested in specifics of the LLVM implementation used by Apple's Xcode, see https://libcxx.llvm.org/ .
For a comprehensive list of the most highly recommended books and references for C++, Stack Overflow already has a very good FAQ regarding this: The Definitive C++ Book Guide and List.
Bjarne Stroustrup gave a keynote presentation today for the Going Native 2012 conference. In his presentation, he discussed the issue of enforcing correct units. His elegant (IMHO) solution to this involved using an operator I have never heard of before: operator"". Using this operator, he was able to write C++ code that looked like this:
ratio = 100m / 1s;
Where operator""m(...) and operator""s(...) were defined.
Does anyone know of any documentation regarding how to actually use this operator (or even if any modern C++ compilers support it)? I tried searching online, but had no luck. Any help would be greatly appreciated.
The syntax you'd be looking for is "user-defined literals" which is a feature of C++11.
g++ versions 4.7 and better support this feature.
Here is some documentation describing the use of that operator overload:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2765.pdf
Also see the excellent link Xeo provides in the comments to your question.
Currently the best documentation is probably in the standard itself. You can get the latest version from the commitee's site. According to gcc's site it will be in the next revision of gcc (gcc-4.7). You should be able to test it when building gcc from the SVN repository.
I'm coming to C++ from a .Net background. Knowing how to use the Standard C++ Libraries, and all the syntax, I've never ventured further. Now I'm looking learning a bit more, such as what libraries are commonly used? I want to start getting into Threading but have no idea to start. Is there a library (similar to how .net has System.Threading) out there that will make it a bit easier? I'm specifically looking to do Linux based network programming.
For C++, Boost is your everything. Threading and networking are among the things it offers. But there's much more:
Smart pointers
Useful containers not found in the STL, such as fixed-size arrays and hashtables
Closures
Date/time classes
A foreach construct
Min/max functions
Command line option parsing
Regular expressions
As the others have said, Boost is great. It implements the C++ Technical Report 1 in addition to tons of other stuff, including some mind-blowing template metaprogramming tricks.
For other cross-platform features not provided by Boost, I've had very good luck with a library called Poco. I've worked on commercial projects that incorporated its simple HTTP server, for instance, and it treated us quite well.
lots of boost suggestions, but Qt is another good option. It's got great support for threading and networking along with pretty much everything else.
http://qt.nokia.com/products
If you are looking into network programming and are not interested into GUI, I suggest Boost libraries: in particular, Asio.
There's no standard multithreading library, but the boost library includes a platform-independent multithreading abstraction that works very well.
I am new (in a way) to C++ programming. I would like to start doing development in Linux using C and/or C++ as programming languages. I have done some development for a while in Java.
Unfortunately I am not sure where to start. Can you point me to some good resources, and also give me an outline as to what would be the primary difference between C and C++ in Windows and Linux?
Any special steps I need to do to get started? Also any good IDEs. I plan to use Eclipse currently. I am using Kubuntu (version 9.x).
IDEs:
QtCreator: http://qt.nokia.com/products/appdev/developer-tools/developer-tools
Kdevelop: http://www.kdevelop.org/
Books:
Thinking in C++ / Bruce Eckel http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html
Brose standard libraries:
http://www.cplusplus.com/reference/iostream/
It is good that you are using a Linux platform as it will help you to program as per the C and C++ standards.
I would recommend
vi/vim --> text editor
gcc --> C compiler
g++ --> C++ compiler
gdb --> Command line debugger
ddd --> GUI debugger
I use the above mentioned tools. If you are hell-bent on IDEs, you can use the ones mentioned by Chen Levy
If you have done development in Java, then you can start with any tutorial on the internet. There are literally hundreds of them!
I don't expect it to be hard since you have a Java background.
Here is a nice tutorial on CPlusPlus.com.
Also, check out this question on StackOverflow: The definitive C book guide and list.
IDE
Eclipse is very good as a starting point.
The new CDT provides a completely set up environment.
Just be sure to install gcc and gdb before
trying out anything.
And don't use the eclipse in the ubuntu repos, download a
current release.
Difference Windows/Linux:
The language standard is completely the same in both worlds. (Compiler implementations vary in fullfillment of the standard, but you shouldn't notice anything in the beginning.)
If you stick to cross-platform tools, compiler(gcc/mingw), ide and debugger it can stay this way. (I imply that the obvious differences, like .so s and .dlls and stuff are known)
If you move over to other compilers and library implementations (MSVisualC++ for instance) it can get interesting in the advanced stages, but it shouldn't be too difficult to bridge the gaps.
Good/essential libs to know:
the stl, boost, and maybe for productivity and ease in the beginning: qt.
These are as platform independent and generally useful as possible. Know them, and they are usable through your complete c++ lifetime.
(Don't make the mistake to want to learn it all in one go, just go step by step.
Don't try template programming in the beginning, it is mind-boggling ;) but using
templates is fun)
IDE / Editor I think with Eclipse you can quite good start with. I perfer emacs and use of the command line tools of gcc. Why? I think you learn more of the basics how they work.
Good libs: STL, QT, boost with these tree you have the ability to create/develop most of the parts you like or you need.
In my opinion very important is that you stuck (in the beginning) to the libray you selected. And also to the IDE/editor.
Starting point: As earlier mentioned Thinking in C++, Second edition (Volume 1 &2) by Bruce Eckel. He trys to explain the difference between C and C++. In volume 1 he explains the basics of C++ and in volume 2 he introduces some parts of the STL.
Another usefull ressource for me was C++ FAQ lite Here you can find a lot of usefull tipps.
If you will ever want some library good places to start are sourceforge.net and freshmeat.net
I'm looking to add full text indexing to a Linux desktop application written in C++. I am thinking that the easiest way to do this would be to call an existing library or utility. This article reviews various open source utilities available for the Gnome and KDE desktops; metatracker, recoll and stigi are all written in C++ so they each seem reasonable. But I cannot find any notable documentation on how to use them as libraries or through an API. I could, instead, use something like Clucene or Xapian, which are generic full text indexing libraries. They seem more straightforward but if I used them, I'd have to implement my own indexing daemon, an unappealing prospect.
Also, Xesam seems to be the latest thing, does anyone have any evidence that it works?
So, does anyone have experience using any of the applications or libraries? How did you use it and what documentation was useful?
I used CLucene, which you mentioned (and also Lucene.NET), and found it to be pretty good.
There's also Strigi which AFAIK works with Xesam and is the default used in KDE.
After further looking around, I found and worked with Recol. It believe that it has the best C++ interface to a full text search engine, in this case Xapian.
It is important to realize that clucene and Xapian are both highly complex libraries designed primarily for multi-user server applications. Cutting them down to a level appropriate for a client-system is not easy. If I remember correctly, Strigi has a complex, pure C interface which isn't adapted.
Clucene also doesn't seem to be that actively maintained currently and Xapian seems to be maintained. But the thing is the existence of recol, which allows you to index particular files without the massive, massive setup that raw Xapian or clucene requires - creating your own "stemming" set is not normally desirable, etc.