title: How should I write classes? C++
body: <p>Hey.. I don't really get them. I read a tutorial about classes in C++, and I don't get a few things:
  In every example and tutorial that I've seen, functions are never written inside the class! For example, why write a class like this:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  class test
  {
      private:
          int x, y;
      public:
          test (int, int);
          int tester () {return x + y; }
  };
  
  test::test (int a, int b)
  {
      x = a;
      y = b;
  }
  
  int main()
  {
      test atest (3, 2);
      test atest2 (2, 6);
  
      cout &lt;&lt; "test1: " &lt;&lt; atest.tester() &lt;&lt; endl;
      cout &lt;&lt; "test2: " &lt;&lt; atest2.tester() &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>
  
  <p>or like this:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  class test
  {
      private:
          int x, y;
      public:
          void set_values (int,int);
          int testfunc () {return x + y; }
  };
  
  void test::set_values (int a, int b)
  {
      x = a;
      y = b;
  }
  
  int main()
  {
      test tester;
  
      tester.set_values (3, 2);
  
      cout &lt;&lt; "test1: " &lt;&lt; tester.testfunc() &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>
  
  <p>instead of simply like this:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  class test
  {
      public:
          int tester (int x, int y) { return x + y; }
  };
  
  int main()
  {
      test atest;
  
      cout &lt;&lt; atest.tester(3, 2) &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>
  
  <p>Honestly, I just don't get it!</p>
  
  <p>Why do I need private members??</p>
  
  <p>When and how should I use destructors?</p>
  
  <p>How should I generally write my classes?</p>
  
  <p>I'm very confused here and I really need somebody to clear up things for me... thanks</p>