I am confused about why am I getting this error when I am pushing elements from outside of the main
function though it works perfectly if I push it from the inside.
#include<iostream>
#include<vector>
using namespace std;
vector<int> vect;
vect.push_back(1);
int main(){
return 0;
}
Output:
main.cpp:6:1: error: ‘vect’ does not name a type
vect.push_back(1);
^~~~
I think I have included std namespace
so it shouldn't throw an error. Could somebody please help me out?