Okay here's what I have so far... The error I receieve is below...

The HCP Header File

#ifndef HEALTHCAREPROVIDER_H
#define HEALTHCAREPROVIDER_H

#include "stdafx.h"
#include <string>
#include <iostream>

using namespace std;

class HealthCareProvider
{
protected:
	string fullName;
	string profession;
	int yearsExperience;
	string companyType;
	string apptAvail;

	double bill;
	double fee;
	
public:
	HealthCareProvider (const string &, const string &, const int &, const string &, const string &);

	void setFullName (const string &);
	string getFullName() const;

	void setProfession (const string &);
	string getProfession() const;

	void setYearsExperience (const int &);
	int getYearsExperience()  const;

	void setCompanyType(const string &);
	string getCompanyType() const;

	void setApptAvail(const string &);
	string getApptAvail() const;
	
	virtual double billForTreatment(...) =0;

	void printInfo() const;
	
};

HealthCareProvider::HealthCareProvider(const string &name, const string &profess, const int &years, const string &coType, const string &appt) 
	: fullName(name), profession(profess), yearsExperience(years), companyType(coType), apptAvail(appt) 
{
	//empty
}

void HealthCareProvider::setFullName(const string &name)
{
	fullName = name;
}

string HealthCareProvider::getFullName() const
{
	return fullName;
}

void HealthCareProvider::setProfession(const string &profess)
{
	profession = profess;
}

string HealthCareProvider::getProfession() const
{
	return profession;
}

void HealthCareProvider::setYearsExperience(const int &years)
{
	yearsExperience = years;
}

int HealthCareProvider::getYearsExperience() const
{
	return yearsExperience;
}

void HealthCareProvider::setCompanyType(const string &coType)
{
	companyType = coType;
}

string HealthCareProvider::getCompanyType() const
{
	return companyType;
}

void HealthCareProvider::setApptAvail(const string &appt)
{
	apptAvail = appt;
}

string HealthCareProvider::getApptAvail() const
{
	return apptAvail;
}

void HealthCareProvider::printInfo() const
{
	cout<<"Name: "<<getFullName()<<endl;
	cout<<"Profession: "<<getProfession()<<endl;
	cout<<"Years Experience: "<<getYearsExperience()<<endl;
	cout<<"Liability: "<<getCompanyType()<<endl;
	cout<<"Appointment Availability: "<<getApptAvail()<<endl;
	cout<<"Bill for Treatment: "<<billForTreatment()<<endl;
}

#endif

The Dentist Header

#ifndef DENTIST_H
#define DENTIST_H

#include "HealthCareProvider.h"

class Dentist : public HealthCareProvider
{
public:
	Dentist(const string &, const string &, const int &, const string &, const string &);

	double billForTreatment(...)
	{return (bill + fee);}

};

#endif

Then the HCP CPP File

// HealthCareProvider.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include "Dentist.h"
#include "HealthCareProvider.h"


int _tmain(int argc, _TCHAR* argv[])
{
	HealthCareProvider *healthptr = new Dentist ("Bob", "Dentist", 5, "LLC", "Available");
	healthptr->billForTreatment(100, 25);
	healthptr->printInfo();

	system("PAUSE");
	return 0;
}

Now my Error that I am receiving...

...visual studio 2010\projects\healthcareprovider\healthcareprovider\healthcareprovider.h(109): error C2662: 'HealthCareProvider::billForTreatment' : cannot convert 'this' pointer from 'const HealthCareProvider' to 'HealthCareProvider &'
1>          Conversion loses qualifiers
1>
1>Build FAILED.

I know where the error is but any alteration I made seems to cause a crap ton of more errors... any ideas? BTW this project is far from complete, but one mistake at a time.

Thanks!

~Climber

Recommended Answers

All 11 Replies

cin.sync();
cin.get();

Instead of system("Pause");

What are you doing this for?

What are you doing this for?

This is a project for one of my college classes.

EDIT: Tried to work around the problem, but now receiving a linking error...

MODIFIED CODE:

#ifndef HEALTHCAREPROVIDER_H
#define HEALTHCAREPROVIDER_H

#include "stdafx.h"
#include <string>
#include <iostream>

using namespace std;

class HealthCareProvider
{
protected:
	string fullName;
	string profession;
	int yearsExperience;
	string companyType;
	string apptAvail;

	double bill;
	double fee;
	
public:
	HealthCareProvider (const string &, const string &, const int &, const string &, const string &);

	void setFullName (const string &name) {fullName = name;} //Just shortened the unecesary lines of code
	string getFullName() const {return fullName;}

	void setProfession (const string &profess) {profession = profess;}
	string getProfession() const{return profession;}

	void setYearsExperience (const int &years) {yearsExperience = years;}
	int getYearsExperience()  const {return yearsExperience;}

	void setCompanyType(const string &coType) {companyType = coType;}
	string getCompanyType() const {return companyType;}

	void setApptAvail(const string &appt) {apptAvail = appt;}
	string getApptAvail() const {return apptAvail;}
	
	virtual double billForTreatment(...) =0;

	void printInfo() ; //REMOVED CONST
	
};

HealthCareProvider::HealthCareProvider(const string &name, const string &profess, const int &years, const string &coType, const string &appt) 
	: fullName(name), profession(profess), yearsExperience(years), companyType(coType), apptAvail(appt) 
{
	//empty
}


void HealthCareProvider::printInfo() //REMOVED CONST
{
	cout<<"Name: "<<getFullName()<<endl;
	cout<<"Profession: "<<getProfession()<<endl;
	cout<<"Years Experience: "<<getYearsExperience()<<endl;
	cout<<"Liability: "<<getCompanyType()<<endl;
	cout<<"Appointment Availability: "<<getApptAvail()<<endl;
	cout<<"Bill for Treatment: "<<billForTreatment()<<endl; 
}

#endif

New error:

1>  HealthCareProvider.cpp
1>HealthCareProvider.obj : error LNK2019: unresolved external symbol "public: __thiscall Dentist::Dentist(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0Dentist@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0ABH00@Z) referenced in function _wmain
1>C:\Documents and Settings\****\My Documents\Visual Studio 2010\Projects\HealthCareProvider\Debug\HealthCareProvider.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.

I hate when VS2010 prints these types of errors, it's hard to translate. Ideas anyone?

Unfortunately the code you postet has nothing to do with the error message (did you try to read it?).

The error message says that you call in main() a constructor of Dentist that the linker cannot find. I would guess you made a mistake in the argument list. But without the pertinent code...

Unfortunately the code you postet has nothing to do with the error message (did you try to read it?).

The error message says that you call in main() a constructor of Dentist that the linker cannot find. I would guess you made a mistake in the argument list. But without the pertinent code...

The Dentist.h code is above... and I've checked my arguements. That's the first place I checked from this link error.
I'm assuming it's has to do with the default Dentist constructor (which I am working again on right now).

The Dentist.h code is above...

Hmmm... I'd like to see your implementation of

Dentist(const string &, const string &, const int &, const string &, const string &);

Hmmm... I'd like to see your implementation of

Dentist(const string &, const string &, const int &, const string &, const string &);

one sec... still working on it... it infact wasn't Dentist (at least what I can see now)... it was HealthCareProvider. I'll post the edited code here in a min.

Edited code... I was wrong about the Dentist implementation... see comments below.

The program runs, but everything is pretty much blank except for the values I put in Dentist's billForTreatment(...).

//HEALTHCAREPROVIDER.H

class HealthCareProvider
{
protected:
	string fullName;
	string profession;
	int yearsExperience;
	string companyType;
	string apptAvail;

	double bill;
	double fee;
	
public:
	HealthCareProvider (const string &, const string &, const int &, const string &, const string &)
		{fullName = name, profession = profess), yearsExperience = years, companyType = coType, apptAvail = appt;}

	HealthCareProvider(){}; //I know the compiler won't run without it but with polymorphism this shouldn't be needed...

	void setFullName (const string &name) {fullName = name;}
	string getFullName() const {return fullName;}

	void setProfession (const string &profess) {profession = profess;}
	string getProfession() const{return profession;}

	void setYearsExperience (const int &years) {yearsExperience = years;}
	int getYearsExperience()  const {return yearsExperience;}

	void setCompanyType(const string &coType) {companyType = coType;}
	string getCompanyType() const {return companyType;}

	void setApptAvail(const string &appt) {apptAvail = appt;}
	string getApptAvail() const {return apptAvail;}
	
	virtual double billForTreatment(...) =0;

	void printInfo() ;
	
};

/*HealthCareProvider::HealthCareProvider(const string &name, const string &profess, const int &years, const string &coType, const string &appt) 
	: fullName(name), profession(profess), yearsExperience(years), companyType(coType), apptAvail(appt) 
{
	//empty DON'T NEED SINCE CODED ABOVE
}*/


void HealthCareProvider::printInfo() 
{
	cout<<"Name: "<<getFullName()<<endl;
	cout<<"Profession: "<<getProfession()<<endl;
	cout<<"Years Experience: "<<getYearsExperience()<<endl;
	cout<<"Liability: "<<getCompanyType()<<endl;
	cout<<"Appointment Availability: "<<getApptAvail()<<endl;
	cout<<"Bill for Treatment: "<<billForTreatment()<<endl;
}
//HEALTHCAREPROVIDER.CPP
int _tmain(int argc, _TCHAR* argv[]){	
HealthCareProvider *healthptr = new Dentist ("Bob", "Dentist", 5, "LLC", "Available");
//healthptr->billForTreatment(100, 55); //Commented out for debug, but still prints 155	
healthptr->printInfo(); 	
system("PAUSE");	
return 0;}
//DENTIST.H
class Dentist : public HealthCareProvider
{
public:	Dentist(const string &, const string &, const int &, const string &, const string &); 	
double billForTreatment(...)	
{return (100 + 55);} //changed to actual values for debug
};
Dentist::Dentist(const string &name, const string &profess, const int &years, const string &coType, const string &appt) 
{
    //Empty -- Here's the Dentist implementation... 
}

I'm still hammering through... trial and error... trial and error...

Okay I think I got it... let me test some more.

SUCCESS!
Thanks guys!

~Climber

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.