// Example class A contains regular and 
// static member variables and methods.

class A
{
private:
  int m_x;
  static int g_y;
  int m_z;

  // Should be invoked when the object ends
  void InformEnd();

public:
  A(int x);
  ~A();
  void UpdateX(int newX);
  static void UpdateY(int newY);
};

// Initialization of the static variable
int A::g_y = 0;

// The non-static member variables 
// are initialized in the constructor
A::A(int x)
{
  m_x = x;
  m_z = 0;
}

// Destructor invokes a private variable
A::~A()
{
  InformEnd();
}

// UpdateX checks the value of X against 
// a static variable before updating the value
void A::UpdateX(int newX)
{
  if (g_y != 0 && m_x < newX)
  {
    m_x = newX;
  }
}

// Unconditional update of static variable m_y
void A::UpdateY(int newY)
{
  g_y = newY;
}

main()
{
    // Create a object on the heap
    A *pA = new A(5);

    // Create an object on the stack
    A a(6);

    // Example of an access via a pointer
    pA->UpdateX(8);

    // Example of a direct access
    a.UpdateX(9);

    // Example of static method call
    A::UpdateY(1000);

    // Deleting the object
    delete pA;
}