An unhandled exception of type 'System, Access Violation Exception' occured in HealthCareProvider.exe
<p>My code compiles but throws an the exception:  "An unhandled exception of type 'System, Access Violation Exception' occured in HealthCareProvider.exe  Additional Information: Attempted to read or write protected memory. . ."  HELP?? </p>

<p>Problem is with print() method. I don't know why. 
Iterator only prints out a bunch different numbers (needs toString ())</p>

<p>Humbly,</p>

<p>Mike</p>

<pre><code>#ifndef _HEALTHCAREPROVIDER_H
#define _HEALTHCAREPROVIDER_H

#include &lt;string&gt;
#include &lt;iostream&gt;

using namespace std;

class HealthCareProvider{

public:

 //constructor
 HealthCareProvider(const string &amp;lname, const string &amp;fname, const string &amp;type, const int &amp;yearsExperience, const string &amp;coType):
 lastName(lname),firstName(fname),providerType(type),yearsExp(yearsExperience),companyType(coType)
 {
 }

 //Last Name
 void setLastName(const string &amp;lname){
  lastName = lname;
 } 

 string getLastName()const{
  return lastName;
 }

 ... etc.

 //coType
 void setCompanyType(const int &amp;coType){
  companyType = coType;
 } 

 string getCompanyType()const{
  return companyType;
 }

 void print() const {
  cout&lt;&lt;"Name: "&lt;&lt; getLastName()&lt;&lt;", " &lt;&lt;getFirstName()&lt;&lt;"\nType : "&lt;&lt;getProviderType()&lt;&lt;"\nYears Experience: "&lt;&lt;getYearsExp()&lt;&lt;" \nCompany Type : "&lt;&lt;getCompanyType()&lt;&lt;endl;
 }

 virtual double billForTreatment() = 0;


private:

 int yearsExperience, yearsExp;
 string type, coType, lname, fname;
 string lastName, firstName, providerType, companyType;


};

#endif




#include &lt;vector&gt;
#include &lt;list&gt;
#include &lt;iostream&gt;
#include &lt;iomanip&gt;
#include &lt;typeinfo&gt;
#include &lt;iterator&gt;
#include "HealthCareProvider.h"
#include "Dentist.h"

using namespace std;

int main (){

  string value;

  cout &lt;&lt; fixed &lt;&lt; setprecision (2);

  //populate 
  vector &lt; HealthCareProvider*&gt; healthCareProviders (6);

  healthCareProviders [0]=new Dentist("Thatcher","Donald","Dentist",10, "sole proprietorship"); 

  healthCareProviders [1]=new Dentist("Parker","Michelle","Dentist",5, "LLC"); 

  healthCareProviders [2]= new Dentist("Bradford","Michael","Dentist",12, "LLC"); 

  healthCareProviders [3] = new Dentist("Craig","Elizabeth","Dentist",4, "sole proprietorship");

  for (size_t i=0; i&lt;healthCareProviders.size(); i++){
   healthCareProviders[i] -&gt;print();
   cout&lt;&lt;endl;
  }

  for (size_t j =0; j&lt; healthCareProviders.size(); j++){
   delete healthCareProviders [j];   
  }


  cout&lt;&lt;"Pause . . ."&lt;&lt;endl;
  cin&gt;&gt;value;

}
</code></pre>
