#include "Shallow.h" #include "Deep.h" #include #include using std::cout; using std::endl; void main() { //this works with a shallow object CShallow ShallowObject1; CShallow ShallowObject2; ShallowObject1.m_Bool = true; ShallowObject1.m_Float = static_cast(5.4); ShallowObject1.m_Interger = 7; ShallowObject2 = ShallowObject1; ShallowObject1.m_Bool = false; ShallowObject1.m_Float = static_cast(10.7); ShallowObject1.m_Interger = 3; cout << ShallowObject2.m_Bool << endl; cout << ShallowObject2.m_Float << endl; cout << ShallowObject2.m_Interger << endl; //this does not work with a deep object CDeep DeepObject1; CDeep DeepObject2; DeepObject1.m_Shallow->m_Bool = true; DeepObject1.m_Shallow->m_Float = static_cast(5.4); DeepObject1.m_Shallow->m_Interger = 7; strcpy(DeepObject1.m_String,"Bubba"); DeepObject2 = DeepObject1; DeepObject1.m_Shallow->m_Bool = false; DeepObject1.m_Shallow->m_Float = static_cast(10.7); DeepObject1.m_Shallow->m_Interger = 3; strcpy(DeepObject1.m_String,"Sammy"); cout << DeepObject2.m_Shallow->m_Bool << endl; cout << DeepObject2.m_Shallow->m_Float << endl; cout << DeepObject2.m_Shallow->m_Interger << endl; cout << DeepObject2.m_String << endl; // this program will crash when the destructors for the deep object are called }