PDA

View Full Version : Doubts about STL libraries



tonnot
22nd September 2010, 10:32
I'm learning c++ and I have a great confusion about standar libraries.

Why QT creator does not provide help about it ? (It is not neccesary to answer to this...)

I dont understand why I must to use std::----- . What is std ? is there more 'workspaces' ( I dont know how to name it) ?

I have found a good reference here, http://www.cplusplus.com/reference/string/, anybody knows other ? A way to get help for inline help into QT Creator ?

Thanks
Moved to general

Zlatomir
22nd September 2010, 10:56
Qt Creator doesn't come with STL documentation because Qt has some "replacement" for the STL's containers, iterators and algorithm.
Like you can use (and it's recommended to use) QString (http://doc.trolltech.com/4.7/qstring.html) instead std::string or std::wstring.

std is the name of the namespace (http://www.cplusplus.com/doc/tutorial/namespaces/) which contains the standard library so that if you have your own class named <for example> string, you don't need to change your class name, because it won't conflict with the standard library std::string (unless you are using namespace std; //thats way it is not recommended to use the std namespace )

I think that knowing STL will help you better understand Qt (especially containers-iterator-algorithm), but it is not necessary to know STL for Qt development;
if you learned STL in Qt you can do one confusion which i did a lot: QList (http://doc.trolltech.com/4.7/qlist.html) is not a linkedlist like std::list, qt has QLinkedList (http://doc.trolltech.com/4.7/qlinkedlist.html)

wysota
22nd September 2010, 11:34
Why QT creator does not provide help about it ? (It is not neccesary to answer to this...)
As you said yourself STL is a standard library, it's not part of Qt. If you deploy help for STL in Creator, it will use it and give you proper reference.


I dont understand why I must to use std::----- . What is std ? is there more 'workspaces' ( I dont know how to name it) ?
These are so called "namespaces". Thanks to that if there is a std::string class, it doesn't conflict with a string class from some other library. You don't have to use std:: prefix, you can declare that you are "using namespace std;" and all symbols from the std namespace will be made available in the default namespace. But then you might get some naming conflicts if you use other libraries.


A way to get help for inline help into QT Creator ?
This has already been answered somewhere on this forum.