// 3.x: classi
#include <iostream>
using namespace std;
class Prova {
public:
// Membri statici
int myint;
char mychar;
float myfloat;
// Metodi
void metodo1();
void metodo2(char a) { /* ... */ };
void set_myint(int nuovo);
int get_myint();
// Static
static int a;
static void static_method(int na);
void show() { cout << "Oggetto prova @" << this << ": a e' " << a << endl; };
};
void Prova::metodo1() {
cout << "Invocato metodo1!\n";
}
void Prova::static_method(int na) {
Prova::a = na;
}
void Prova::set_myint(int nuovo) {
myint = nuovo;
}
int Prova::get_myint() {
return myint;
}
int Prova::a = 10;
int main() {
Prova a, b, c;
a.set_myint(4);
b.set_myint(3);
c.set_myint(2);
cout << "a: " << a.get_myint() << endl;
cout << "b: " << b.get_myint() << endl;
cout << "c: " << c.get_myint() << endl;
a.show();
b.show();
c.show();
//a.metodo_statico(); // ERRORE
Prova::static_method(3);
a.show();
b.show();
c.show();
}