Re: What can't I make a call in global scope?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"孙宗君" <szj087@xxxxxxxxx> writes:

> Why the following code is illegal?
>
>
> #include <iostream>
> #include <vector>
>
> vector<int > vi;
>
> vi.push_back(10); //why this line is illegal?
> int ii = vi.at(0); // this line is legal??

This is a basic C++ question.  It has nothing to do with gcc.  Please
ask questions of this sort on a C++ language mailing list.

The answer is simply that statements are not permitted at top level.
Variable initializations are permitted.

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux