Can we have vector of vector?
e.g.
vector <vector<string>>vBig;
Can we have vector of vector?
e.g.
vector <vector<string>>vBig;
Yes.
hth
-nv
She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."
When in doubt, read the FAQ.
Then ask a smart question.
Thanks a lot nvoigt. :-)
But you need to put a space between the two >, or the compiler will parse it as a >> operator.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
Yeah, and another thing I hate about MSVC is that it doesn't complain if you forget to include a standard header file and silently includes it for you. Then you try compiling on UNIX and get errors about the missing header files. Maybe there's a switch to turn off that "feature", but I haven't been motivated enough to look for it yet.
It does no such thing. It's just that some standard library parts are implemented in terms of other parts. For example, some parts of <locale> require the std::string class. Also, some parts of the stream library require locales. Thus, when you #include <iostream>, you get parts of the locale system and thus parts of the string library.
This problem affects all standard libraries, but to different degrees. Some go to greater pains in order to avoid this stuff, others to lesser. In one library you may get A by including B, in the other you may get B by including A. And so on.
Nothing MS-specific.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
Oh I would have to disagree with the "Nothing MS-specific" part. If you forget even a single header file gcc will complain, but MSVC compiles without so much as a peep. Whether this is intentional or simply because required headers were included by other headers, I don't know, but the result is annoying nonetheless.
Thanks a lot CornedBee
AFAIK, MSVC has been smart enough to spot inccorect usage of templates in form of >> since earlier versions. It would complain >> is invalid with templates, it must be > >, but it doesn't report syntax error. It's just Microsoft went one step further to eleminate the restriction in later versions.
I don't really understand why the standard specifies you must use > > either, since it's rather absurd. It doesn't really matter if it can be mistaken for the operator or not, since it's the compiler vendor's work to make sure it works. It messes up style too. Microsoft's compiler can do it, so why not others?
Allowing '>>' in template declarations seems like a simple enough requirement, but the amount of work required in the compiler's parser would be ridiculous in comparison to the benefit of allowing it, which is practically zero.
And the idea of a standards body is to formalize and enhance existing practice, not to subject implementers to onerous, pointless requirements. It's not, "We create the standard and now you have to do it this way," it's practically the exact opposite.
Looking on the good side, at least the non-portable code will become standard (and hopefully portable) in a few years' time (C++0x).According to the standard probably, but newer versions of MSVC have actually been made smart enough to work out what you mean when you use >> there, if it can.
Note that this is not really a good thing either as it encourages you to write non-portable code.
The principle of greedy matching. However, eventually the C++ standard committee people decided that it is better to just let the more natural syntax be used, thus the change.I don't really understand why the standard specifies you must use > > either, since it's rather absurd.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
There's an option to turn off Microsoft extensions. Only problem is that it's rather useless since it produces tons of errors if you include typical Windows headers!
I'm thinking you should be able to turn off (and on) an option dynamically; otherwise it's rather useless.
Here's an example where <cstdio> & <cstring> are required, but VC++ compiles it anyways. They're probably included in <iostream> because if you remove that, you get the expected errors.
Code:#include <iostream> //#include <cstdio> //#include <cstring> using namespace std; int main() { char str[] = "fdsfsdfsdfs"; printf( "str has %d chars", strlen( str ) ); return 0; }