1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef AB_H 10 #define AB_H 11 12 #include <cassert> 13 14 class A 15 { 16 int id_; 17 public: A(int id)18 explicit A(int id) : id_(id) {++count;} A(const A & a)19 A(const A& a) : id_(a.id_) {++count;} ~A()20 virtual ~A() {assert(id_ >= 0); id_ = -1; --count;} 21 22 static int count; 23 }; 24 25 int A::count = 0; 26 27 class B 28 : public A 29 { 30 public: B(int id)31 explicit B(int id) : A(id) {++count;} B(const B & a)32 B(const B& a) : A(a) {++count;} ~B()33 virtual ~B() {--count;} 34 35 static int count; 36 }; 37 38 int B::count = 0; 39 40 #endif // AB_H 41