title: Classes in header files - not able to compile?
body: <p>I'm a newbie to c++. I am trying to create header files in c++ to put classes in them and include it in the main fn. Everything works fine when i declare only functions(not class member fns.) in .h file and their definition in a .cpp file of same name. But it gives some error while compiling a project when classes have been defined in the header file! Please help me in solving this problem as I did not find anything useful on the net (google).</p>
  
  <p>Here is my code :</p>
  
  <pre><code>// STUDENT.h
  #ifndef STUDENT
  #define STUDENT
  
  class STUDENT
  {
  private :
  int marks;
  public :
  void setMarks(int);
  void getMarks();
  };
  
  #endif
  </code></pre>
  
  <p>//STUDENT.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "STUDENT.h"
  
  void STUDENT :: setMarks(int x)
  {
  marks = x;
  }
  
  void STUDENT :: getMarks()
  {
  cout &lt;&lt; marks;
  }
  </code></pre>
  
  <p>// main.cpp</p>
  
  <pre><code>#include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  #include "STUDENT.h"
  
  using namespace std;
  
  int main(int argc, char *argv[])
  {
  system("PAUSE");
  return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>Additional Details
  Errors show on dev c++ :</p>
  
  <p>(3)in file included from main.cpp
  (5)an anonymous union can't have fn. members
  (11)abstract declarator ' ' used as declaration
  (11)namespace-scope anonymous aggregates must be static</p>
  
  <p>P.S I still haven't used objects of class in main. just wanted to test it b4 writing actual program</p>