title: How Access of global data member and member function in a class?
body: <p>I have declare a global data and global function,when i try to access in a class compiler throw error as "  i cannot appear in constant expression",why?</p>
  
  <pre><code>  #include&lt;iostream&gt;
    using namespace std;
    int i=20;
  
    void fn()
    { 
      cout&lt;&lt;" I am outside class"&lt;&lt;endl;
    }
  
    class a
    {
        public: 
  
          int x= ::i;  // error is  i cannot appear in constant expression
  
          void accessGlobal()
          {
  
             ::fn();      //fn() is being called
          }
    };
  
    int main()
    {
       a obj;
       obj.accessGlobal();
    }
  </code></pre>