1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef AB_H 11#define AB_H 12 13#include <cassert> 14 15class A 16{ 17 int id_; 18public: 19 explicit A(int id) : id_(id) {++count;} 20 A(const A& a) : id_(a.id_) {++count;} 21 virtual ~A() {assert(id_ >= 0); id_ = -1; --count;} 22 23 static int count; 24}; 25 26int A::count = 0; 27 28class B 29 : public A 30{ 31public: 32 explicit B(int id) : A(id) {++count;} 33 B(const B& a) : A(a) {++count;} 34 virtual ~B() {--count;} 35 36 static int count; 37}; 38 39int B::count = 0; 40 41#endif // AB_H 42