title: Call class constructor from new operator on GNU - use invalid class
body: <p>The closest thread to my question is <a href="https://stackoverflow.com/questions/2941888/how-operator-new-calls-the-constructor-of-class">here</a>. I am trying to compile the following code with gcc:</p>
  
  <pre><code>#include &lt;malloc.h&gt;
  
  class A
  {
  public:
    A(){};  
    ~A(){};
  };//class A
  
  int main()
  {
    A* obj = (A*) malloc( sizeof(A) );
    if(obj==0) return 1 ;
    obj-&gt;A::A(); /*error: invalid use of 'class A' */
    obj-&gt;A::~A();
    free(obj);
    return 0;  
  };//
  </code></pre>
  
  <p>From the command line I compile the code with:  </p>
  
  <pre>$ g++ -o main main.cpp  
  main.cpp: In function 'int main()':  
  main.cpp:22: error: invalid use of 'class A'</pre>
  
  <p>Can you please point me in the right direction?</p>