#include <iostream>
using namespace std;

class IntVal
{ 
private:
  int value {0};       
  static int valCount;     // use static in variable declaration
public:
  IntVal() { valCount++; } // constructor is used to increment static variable
  int getVal() { return value; }
  int getValCount() { return valCount; }
};

int IntVal::valCount {0};  // static variable must be defined outside of the class


int main()
{

  IntVal v1;
  cout << v1.getValCount() << endl;
  cout << "----------" << endl;

  IntVal v2;
  cout << v1.getValCount() << endl;
  cout << v2.getValCount() << endl;
  cout << "----------" << endl;
  
  IntVal v3;
  cout << v1.getValCount() << endl;
  cout << v2.getValCount() << endl;
  cout << v3.getValCount() << endl;
  cout << "----------" << endl;
  
  
  return 0;
}
