|
#include <memory>
#include <iostream>
using namespace std;
class Test
{
public:
Test(int a = 0) : m_a(a) { }
~Test( )
{
cout<<"Test object is destroyed whose value is = "<<m_a<<endl;
}
public:
int m_a;
};
//*********************************************************************************************************
class B;
class A
{
public:
A()
{
}
~A( )
{
cout<<"DestructorA is called"<<endl;
}
shared_ptr<B> m_spToB;
};
//*********************************************************************************************************
class B
{
public:
B()
{
}
~B()
{
cout<<"DestructorB is called"<<endl;
}
shared_ptr<A> m_spToA;
};
//*********************************************************************************************************
class D;
class C
{
public:
C()
{
}
~C()
{
cout<<"DestructorC is called"<<endl;
}
weak_ptr<D> m_wpToD;
};
//*********************************************************************************************************
class D
{
public:
D()
{
}
~D()
{
cout<<"DestructorD is called"<<endl;
}
weak_ptr<C> m_wpToC;
};
//*********************************************************************************************************
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I'm working as Senior software Engineer since 7 years and interested in MFC and COM programming.