title: Vector of Object Pointers, general help and confusion
body: <p>Have a homework assignment in which I'm supposed to create a vector of pointers to objects</p>
  
  <p>Later on down the load, I'll be using inheritance/polymorphism to extend the class to include fees for two-day delivery, next day air, etc. However, that is not my concern right now. The final goal of the current program is to just print out every object's content in the vector (name &amp; address) and find it's shipping cost (weight*cost).</p>
  
  <p>My Trouble is not with the logic, I'm just confused on few points related to objects/pointers/vectors in general. But first my code. I basically cut out everything that does not mater right now, int  main, will have user input, but right now I hard-coded two examples.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  using namespace std;
  
  class Package {
  public:
      Package(); //default constructor
      Package(string d_name, string d_add, string d_zip, string d_city, string d_state, double c, double w);
      double calculateCost(double, double);
      ~Package();
  
  private:    
      string dest_name;
      string dest_address;
      string dest_zip;
      string dest_city;
      string dest_state;
      double weight;
      double cost;
  
  };
  
  Package::Package()
  {
      cout&lt;&lt;"Constucting Package Object with default values: "&lt;&lt;endl;
      string dest_name="";
      string dest_address="";
      string dest_zip="";
      string dest_city="";
      string dest_state="";
      double weight=0;
      double cost=0;
  }
  Package::Package(string d_name, string d_add, string d_zip, string d_city, string d_state, string r_name, string r_add, string r_zip, string r_city, string r_state, double w, double c){
  
      cout&lt;&lt;"Constucting Package Object with user defined values: "&lt;&lt;endl;
      string dest_name=d_name;
      string dest_address=d_add;
      string dest_zip=d_zip;
      string dest_city=d_city;
      string dest_state=d_state;
      double weight=w;
      double cost=c;
  }
  Package::~Package()
  {
      cout&lt;&lt;"Deconstructing Package Object!"&lt;&lt;endl;
      delete Package;
  }
  double Package::calculateCost(double x, double y){
      return x+y;
  }
  int main(){
      double cost=0;
      vector&lt;Package*&gt; shipment;
      cout&lt;&lt;"Enter Shipping Cost: "&lt;&lt;endl;
      cin&gt;&gt;cost;
      shipment.push_back(new Package("tom r","123 thunder road", "90210", "Red Bank", "NJ", cost, 10.5));
      shipment.push_back(new Package ("Harry Potter","10 Madison Avenue", "55555", "New York", "NY", cost, 32.3));
      return 0;
  
  }
  </code></pre>
  
  <p>So my questions are: </p>
  
  <ol>
  <li>I'm told I have to use a vector
  of Object Pointers, not Objects.
  Why? My assignment calls for it
  specifically, but I'm also told it
  won't work otherwise.</li>
  <li>Where should I be creating this
  vector?
      Should it be part of my Package
      Class? How do I go about adding
      objects into it then?</li>
  <li><p>Do I need a copy constructor? Why?</p></li>
  <li><p>What's the proper way to deconstruct
  my vector of object pointers?</p></li>
  </ol>
  
  <p>Any help would be appreciated. I've searched for a lot of related articles on here and I realize that my program will have memory leaks. Using one of the specialized ptrs from boost:: will not be available for me to use. Right now, I'm more concerned with getting the foundation of my program built. That way I can actually get down to the functionality I need to create.</p>
  
  <p>Thanks. </p>