C++:Segmentation Fault When Attempting to Copy a Class via pointers and functions
<p>The object of this last step of the code is to create a temporary instance of a class, use a set on a private data member of the class, print out the instance while it remains in scope and then use a destructor that takes care of the pointer and the class instance. I am getting the segmentation fault error, I've been getting it for a while even with a lot of changes so Its frustrating me greatly .</p>

<pre><code> #include &lt;cstdlib&gt;
 #include &lt;iostream&gt;
 #include &lt;cstring&gt;

using namespace std;


//Class Definition

class Box{

      //Private data members
      private:
      int height;
      int width;
      int depth;
      char *name;
      void pri_setname(char *n);

      public:
      //Public constructors and deconstructor
      Box(int,int,int,char *);
      Box(const Box &amp;obj);
      ~Box();
      //Public function prototypes
      void width_set(int w);
      void height_set(int h);
      void depth_set(int d);
      void name_set(char *n);
      void name_print();
      int volume_print();
      void objCreateKeep(Box **, char *n);
      void objCreateTmp(char *n);
};

//Default constructor
Box::Box(int h1 = 1,int w1 =1, int d1 =1,char *n1 = "Blue Box")
{
  strcpy(name,n1);
  height = h1;
  width = w1;
  depth  = d1;

}
//Copy constructor
Box::Box(const Box &amp;obj)
{
  name = new char[25];
  strcpy(name,obj.name);
  height = obj.height;
  width = obj.width;
  depth = obj.depth;
}
//Destructor
Box::~Box()
{
  delete [] name;
  cout&lt;&lt;"Destructor invoked, name pointer is deallocated";
}

void Box::pri_setname(char *n)
{
   strcpy(name,n);  
}

//Set the width of Box()
void Box::width_set(int w)
{
     width = w;
}

//Set the height of Box()
void Box::height_set(int h)
{
     height = h;
}

//Set the depth of Box()
void Box::depth_set(int d)
{
     depth = d;
}

//Set the name of Box()
void Box::name_set(char *n)
{
    name = new char[30];
    strcpy(name,n);
    pri_setname(name);
}

//Prints the name of the box
void Box::name_print()
{
  cout&lt;&lt;"Box Name: "&lt;&lt;name;
}

//Calculate and Print volume of Box()
int Box::volume_print()
{
   int volume = 0;
   volume = height * width * depth;
   return volume ;
}


void Box::objCreateTmp(char *n)
{
   Box tmp;
   tmp.name_set(n);
   tmp.name_print();
   tmp.~Box();
}

void Box::objCreateKeep(Box **pp, char *n)
{
  Box *p = new Box;
  pp = &amp;p;
  p-&gt;objCreateTmp(n);
  delete p;
}


int main(int argc, int argv[])
{

    //Check for correct # of cmd line args
    /*
    if(argc != 3)
    {
      cout&lt;&lt;"Wrong number of arguments";
    }
    */
/*
    Box a;
    a.height_set(argv[1]);
    a.width_set(argv[2]);
    a.depth_set(argv[3]);

    Box b = a;
    Box c = a;

    //Set the names of box B and C
    b.name_set("Red Box");
    c.name_set("Orange Box");

    a.name_print();
    b.name_print();
    c.name_print();


*/
    Box *keep;
    Box **pp;

    keep-&gt;objCreateKeep(pp,"Blue Box");
    keep-&gt;objCreateKeep(pp,"Red Box");
    keep-&gt;objCreateKeep(pp,"Orange Box");


    system("PAUSE");
    return(0);
}
</code></pre>
