Skip to content

Instantly share code, notes, and snippets.

@thinkphp
Created May 3, 2026 09:08
Show Gist options
  • Select an option

  • Save thinkphp/6768d04e7597286209d99e7e2ceae8f9 to your computer and use it in GitHub Desktop.

Select an option

Save thinkphp/6768d04e7597286209d99e7e2ceae8f9 to your computer and use it in GitHub Desktop.
Exemplu utilizare static
#include <iostream>
using namespace std;
class Contor {
private:
static int numarObiecte;
public:
Contor() {
numarObiecte++;
}
static int getNumarObiecte() {
return numarObiecte;
}
};
int Contor::numarObiecte = 0;
int main(int argc, char const *argv[])
{
Contor a, b, c;
cout<<"Numar de obiecte: "<<Contor::getNumarObiecte()<<endl;
//class::metoda
//class::variabila_statica
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment