Static
Static Function and Static Attribues
//Object.h
#ifndef OBJECT_H
#define OBEJCT_H
class Object
{
	private:
		static int num;
		int index;
	public:
		Object(int i)
		{
			num++;
			index = i;
		}
		int getIndex() const {return index;}
		static int getNum() {return num;}
};
int Object::num = 0;
#endif

//main.cpp
#include <iostream>
#include "Object.h"

int main(int argc, char *argv[])
{
	Object o1(1);
	std::cout<<Object::getNum()<<": "<<o1.getIndex()<<std::endl;

	Object o2(10);
	std::cout<<o2.getNum()<<": "<<o2.getIndex()<<std::endl;

	return 0;
}