antivirus popup while using c++

  access-denied, c++

I am new to C++.I am following tutorial on C++.
The program looks like this-

#include <iostream>
#include <cmath>

using namespace std;

int main() 
  int luckyNums[] = {4,8,15,16,23,42};
  cout << luckyNums[2];

  return 0;   

since I had VS code already installed I did not install code blocks.
Every time I run the above program I get an error "Access is denied". Also at the same time McAfee pops up saying "we just stopped a virus". I couldn’t find a solution to this on Google anywhere.
When I was trying to do something with the code, in line 6 I did

cout << luckyNums[2] << endl;

and it worked and returned 15 but now the problem was I didn’t understand why it worked because Mike got the result without doing this in code blocks.
Mike is the person giving the tutorial on

Source: Windows Questions C++