28 Ott 2002
Costruzione di Interfacce - Paolo Cignoni
8
Classi
•[Foo.java]
public class Foo        // declare a class Foo
{
    protected int m_num; // declare an instance variable of type int
    public Foo()        // declare and define a constructor for Foo
    {
      m_num = 5;      // the constructor initializes the m_num variable
    }
}
•[Foo.H]
class Foo               // declare a class Foo
{
public:                 // begin the public section
   Foo();               // declare a constructor for Foo
protected:              // begin the protected section
   int m_num;            // declare an instance variable of type int
};

[Foo.C]
#include "Foo.H"

Foo::Foo()              // definition for Foo's constructor
{
   m_num = 5;            // the constructor initializes the m_num
                        // instance variable
}