| 1 |
// { dg-do assemble } |
| 2 |
// Origin: Loring Holden <[email protected]> |
| 3 |
|
| 4 |
template <class T> |
| 5 |
class REFptr { |
| 6 |
public: |
| 7 |
virtual ~REFptr(); |
| 8 |
REFptr<T> &operator = (const REFptr<T>& p); |
| 9 |
}; |
| 10 |
|
| 11 |
class STR { }; |
| 12 |
class str_ptr : public REFptr<STR> { }; |
| 13 |
|
| 14 |
template <class T> |
| 15 |
class ARRAY { |
| 16 |
protected: |
| 17 |
T *_array; |
| 18 |
int _num; |
| 19 |
int _max; |
| 20 |
public: |
| 21 |
virtual void realloc(int new_max) { |
| 22 |
_max = new_max; |
| 23 |
T *tmp = new T [_max]; |
| 24 |
if (tmp == 0) return; |
| 25 |
for (int i=0; i<_num; i++) { |
| 26 |
tmp[i] = _array[i]; |
| 27 |
} |
| 28 |
delete [] _array; |
| 29 |
_array = tmp; |
| 30 |
} |
| 31 |
}; |
| 32 |
|
| 33 |
int |
| 34 |
main() |
| 35 |
{ |
| 36 |
ARRAY<str_ptr> tags; |
| 37 |
} |