This below is my code:
#include <iostream>
#include <vector>
using namespace std;
vector<int> vec;
int main() {
cout << "Hello World!" << endl;
return 0;
}
I use g++ to compile the code.It can be compiled successfully,but I can't see anything in CMD when I run the code.Then I delete the line:
vector<int> vec;
The code can print "Hello World!" in CMD.
Questions:
If we can't use global variable of vector?
Why the situation occurs?
Any help will be appreciated!
I ran this code on visual studio , gcc and on g++. Its result is hello world with or without "vector vec;".
please check it again..
Which command you are executing for compiling;
like this :- g++ program_name -o any_name
or something else.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.