28 Ott 2002
Costruzione di Interfacce - Paolo Cignoni
10
•[Foo.H]
class Foo {
public:
    Foo();
    ~Foo();
    int myMethod(int a, int b);
};  // note the semicolon after the class declaration!

[Foo.C]
#include "Foo.H"
#include <iostream>

Foo::Foo()  // scope operator :: helps define constructor for class Foo
{
    cout << "I am a happy constructor that calls myMethod" << endl;
    int a = myMethod(5,2);
    cout << "a = " << a << endl;
}

Foo::~Foo()
{
    cout << "I am a happy destructor that would do cleanup here." << endl;
}

int Foo::myMethod(int a, int b)
{
    return a+b;
}