
384 Constructors and Destructors
getch();
}
OUTPUT
Number of Objects exists: 1
Number of Objects exists: 2
Number of Objects exists: 3
Press any key to destroy object
Number of objects exists: 2
Number of objects exists: 1
Number of objects exists: 0
Explanation: In this program, the class man has one static data member no. The static data mem-
ber is initialized to zero. Only one copy of static data member is created and all objects share the
same copy of static data member.
In function main(), objects A, B, and C are declared. When objects are declared, con-
structor is executed and static data member no is increased with one. The constructor also ...