title: Static variable shadowing global
body: <p>I am trying to create an object using <code>placement new</code> (I know to use smart pointers, this is just to learn). My code is as follows:</p>
  
  <pre><code>#include &lt;vector&gt;
  #include &lt;iostream&gt;
  #include &lt;memory&gt;
  
  
  using namespace std; // please excuse this
  
  // if you change like 19 to arr1 (or any other var name) instead of arr and line 40 to arr1 then it works
  
  struct A
  {
      int in = 999;
      A()
      {cout &lt;&lt; "A ctor\n";}
      ~A()
      {cout &lt;&lt; "A dtor\n";}
  };
  
  char arr[sizeof(A)];
  
  class B
  {
      public:
      static char arr[sizeof(A)];
  
      const static A* a_obj;
  
      B()
      {
          cout &lt;&lt; "B ctor\n";
          //cout &lt;&lt; (a_obj-&gt;in) &lt;&lt; endl;
      }
      ~B()
      {
          cout &lt;&lt; "B dtor\n";
      }
  };
  
  
  
  const A* B::a_obj = new(arr) A;
  
  
  int main()
  {
      B g;
  }
  </code></pre>
  
  <p>I have created a <code>global array</code> named arr and another <code>array</code> named <code>arr</code>in <code>B</code>. It seems like when I do my <code>placement new</code> the <code>arr</code> being used is from the class as I get what I think are linker errors.</p>
  
  <p>Why is this happening? why isn't the <code>global arr</code> being used? If i change the <code>placement new</code> to use my renamed <code>global array</code> it works. I think it has to do something with <code>lookups</code> but I don't have a concrete answer.</p>