[SOLVED] arrays?
-
-
Follow this link...I think this may help you...
-
In C++, arrays always have indizes. If you want to achieve, what you wrote with
@
arr[int][“string”] = “string”
@logically, it would be
@
QVector< QMap<QString, QString> > ...
@But the way, you write it, seems like you are coming from something like VB or script languages, not from C/C++?
-
[quote author="xeroblast" date="1292925027"]the spaces between the ">" & ">" is my mistake..[/quote]
That is really not so straigthforward, you should know that C/C++ has a '>>' operator (which is heavily used in some cases as it is overloaded for stream inputs) to understand this issue.
-
bq. xeroblast wrote:
cant use C++ arrays in Qt...This is not a C/C++ array: arr[int][“string”]
In C/C++ arrays always use indizes.
You have a combination of an array (or vector) and a map (mapping of string to value). If you want to achieve that, you have to use the proper classes. In php, you don't decide, whether it's a vector or a map. and perhaps var[int] is a map in php, who knows.... -
Gerolf, is absolutely right, this is not a C++ array as strictly speaking C++ is built on C's array construct which should have always int like indexes. But using C++ object oriented feature, especially operator overloading you can easily achieve that this construct can be used and this is usually provided in several libraries like STL or in our case Qt.
-
Anyway you can find really good C++ books on "this":http://developer.qt.nokia.com/wiki/Books_and_Links_for_learning_C_and_advanced_topics page (or you can find lots of online references and books, as well). Mastering C++ is almost a lifetime activity.