%description: Subclassing cObject: *must* take ownership of members subclassed from cObject. Note take(&y) call in the code below. If it wasn't there, crash would occur at end of simulation because double destruction of 'y': both the simple module (which is by default the owner of all objects) and X destructor will call y's destructor. %global: class Noisy : public cObject { public: Noisy(const char *name=NULL) : cObject(name) {ev << "noisy born\n";} ~Noisy() {ev << "noisy died\n";} }; class X2 : public cObject { public: Noisy y; X2() : cObject() { take(&y); // try to comment this out and watch what happens } ~X2() { } }; %activity: X2 *x = new X2(); x->y.setName("yname"); %contains-regex: stdout noisy born.* noisy died %not-contains-regex: stdout noisy died.* noisy died