|
Boost : |
From: Powell, Gary (powellg_at_[hidden])
Date: 2004-02-11 14:54:21
One other thing that makes writing base class and derived classes easier is to add this to the ref struct
class X {
....
private:
struct ref {
ref (X *rhs) : p (rhs) {}
template<class T> // new
ref (T *rhs) : p(rhs) {} // compiles if T is derived from X.
X *p;
};
.....
};
Then in the derived class you can call:
class Y : public X {
....
Y(ref rhs)
: X (rhs.p) // no cast needed to call X::ref
, id(++cnt)
, owner(true)
{
....
}
....
};
Anyway the more I play with this the better I like it.
Yours,
-Gary-
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk