Node: Dynamic Allocation of Shapes, Next: System Information, Previous: Global Constants and Variables, Up: Top
template <class C> C* create_new (const C* arg)
|
Template function |
template <class C> C* create_new (const C& arg)
|
Template function |
These functions dynamically allocate an object derived from
Shape on the free store,
returning a pointer to the type of the Shape and setting
on_free_store to true .
If a non-zero pointer or a reference is passed to It is not possible to instantiate more than one specialization of
Point* p = create_new<Point>(0); p->show("*p:"); -| *p: (0, 0, 0) Color c(.3, .5, .25); Color* d = create_new<Color>(c); d->show("*d:"); -| *d: name == use_name == 0 red_part == 0.3 green_part == 0.5 blue_part == 0.25 Point a0(3, 2.5, 6); Point a1(10, 11, 14); Path q(a0, a1); Path* r = create_new<Path>(&q); r->show("*r:"); -| *r: points.size() == 2 connectors.size() == 1 (3, 2.5, 6) -- (10, 11, 14); Specializations of this template function are currently declared for
|