60 lines
925 B
C++
60 lines
925 B
C++
#include <rcp.h>
|
|
#include <cassert>
|
|
|
|
static int mybase_construct;
|
|
static int mybase_destruct;
|
|
static int myderived_construct;
|
|
static int myderived_destruct;
|
|
|
|
class MyBase
|
|
{
|
|
rcp_root();
|
|
|
|
protected:
|
|
MyBase(int x, int y)
|
|
{
|
|
mybase_construct++;
|
|
}
|
|
|
|
virtual ~MyBase()
|
|
{
|
|
mybase_destruct++;
|
|
}
|
|
|
|
public:
|
|
rcp_managed(MyBase);
|
|
};
|
|
|
|
class MyDerived : public MyBase
|
|
{
|
|
protected:
|
|
MyDerived(double v) : MyBase(1, 2)
|
|
{
|
|
myderived_construct++;
|
|
}
|
|
|
|
virtual ~MyDerived()
|
|
{
|
|
myderived_destruct++;
|
|
}
|
|
|
|
public:
|
|
rcp_managed(MyDerived)
|
|
};
|
|
|
|
void t1()
|
|
{
|
|
rcp<MyBase> mybase = MyBase::create(4, 5);
|
|
rcp<MyDerived> myderived = MyDerived::create(42.5);
|
|
}
|
|
|
|
int main(int argc, char * argv[])
|
|
{
|
|
t1();
|
|
assert(mybase_construct == 2);
|
|
assert(mybase_destruct == 2);
|
|
assert(myderived_construct == 1);
|
|
assert(myderived_destruct == 1);
|
|
return 0;
|
|
}
|