Nieuws:

Welkom, Gast. Alsjeblieft inloggen of registreren.
Heb je de activerings-mail niet ontvangen?

Auteur Topic: [C++] Probleem met class definitie  (gelezen 981 keer)

Offline Joshua822

  • Lid
[C++] Probleem met class definitie
« Gepost op: 2009/12/11, 18:45:22 »
Hoi.

Stel dat ik een class zo declareer in C++ :
class test_class
{
  public:
    static unsigned short n;
    test_class ( ) { test_class::n++; }
    ~test_class ( ) { test_class::n--; }
};

Of zo :

public class test_class
{
  static unsigned short n;
  test_class ( ) { test_class::n++; }
  ~test_class ( ) { test_class::n--; }
};

Waarom kan g++ dan een programma waar het tweede voorbeeld wordt gebruikt niet compileren ?

Alvast bedankt.

Re: [C++] Probleem met class definitie
« Reactie #1 Gepost op: 2009/12/11, 18:47:48 »
Hoi.

Stel dat ik een class zo declareer in C++ :
class test_class
{
  public:
    static unsigned short n;
    test_class ( ) { test_class::n++; }
    ~test_class ( ) { test_class::n--; }
};

Of zo :

public class test_class
{
  static unsigned short n;
  test_class ( ) { test_class::n++; }
  ~test_class ( ) { test_class::n--; }
};

Waarom kan g++ dan een programma waar het tweede voorbeeld wordt gebruikt niet compileren ?

Alvast bedankt.
Omdat C++ geen Java is (m.a.w. er bestaat niets zoals 'public class')
I use a Unix-based system, that means I'll get laid as often as I have to reboot.
LibSylph
SeySayux.net