| 1 |
// { dg-do run } |
| 2 |
// PRMS Id: 11596 |
| 3 |
|
| 4 |
#include <typeinfo> |
| 5 |
extern "C" int printf (const char *, ...); |
| 6 |
|
| 7 |
class Chicken |
| 8 |
{ |
| 9 |
public: |
| 10 |
int eggs_per_day; |
| 11 |
}; |
| 12 |
|
| 13 |
template <class Bird> |
| 14 |
class Flock |
| 15 |
{ |
| 16 |
public: |
| 17 |
Bird * flock_head; |
| 18 |
int head_count; |
| 19 |
void print_self() { |
| 20 |
printf ("A flock of %d %ss\n", head_count, typeid (Bird).name ()); |
| 21 |
printf ("A flock of %d %ss\n", head_count, typeid (*flock_head).name ()); |
| 22 |
} |
| 23 |
}; |
| 24 |
|
| 25 |
int main() |
| 26 |
{ |
| 27 |
Flock<Chicken> x; |
| 28 |
printf ("%s\n", typeid(x).name()); |
| 29 |
x.head_count = 42; |
| 30 |
x.print_self(); |
| 31 |
} |