C++ Program to display Information about Medical personal

Having a difficult time writing a code to display the information on medical personal, this is what i have so far.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
]#pragma once
#include<string>
using namespace std;

class MedicalProfessional
{
private:
	string firstName;
	string lastName;
	string address;
	string city;
	string state;
	string zip;
	string cellPhone;

public:
	MedicalProfessional();
	MedicalProfessional(string, string, string, string, string, string, string);
	~MedicalProfessional();

	string getFirstName();
	void setFirstName(string);
	string getLastName();
	void setLastName(string);
	string getAddress();
	void setAddress(string);
	string getCity();
	void setCity(string);
	string getState();
	void setState(string);
	string getZip();
	void setZip(string);
	string getCellPhone();
	void setCellPhone(string);

	string DisplayInformation();
};
string MedicalProfessional::DisplayInformation()
{
	string tempString = "";
	tempString += "Name: " + getFirstName() +
		" " + getLastName() + ", " + getAddress() + ", " + getCity() 
		+ ", " + getState() + ", " + getZip() + "\n";
	tempString += "Cell Phone: " + getCellPhone(); 
	return tempString;
}
#pragma once
#include "MedicalProfessional.h"
#include<string>
using namespace std;
class Nurse :
    public MedicalProfessional
{
private:
    string type;
    bool certificationCPR;
public:
    Nurse();
    Nurse(string, bool, string, string, string, string, string, string, string);
    ~Nurse();

    string getType();
    void setType(string);

    bool getCertificationCPR();
    void setCertificationCPR(bool);

    string DisplayInformation();

};
string Nurse::DisplayInformation()
{
	string tempString = "";
	tempString = MedicalProfessional::DisplayInformation() + "\n";
	tempString += "CPR Certified: ";
	if (getCertificationCPR())
	{
		tempString += "Yes\n";
	}
	else
	{
		tempString += "No\n";
	}		
	tempString += "Type: " + getType() + "\n";
	return tempString;
}
#pragma once
#include "MedicalProfessional.h"
class PA :
    public MedicalProfessional
{
private:
    string licenseNumber;
    string specialty;
public:
    PA();
    PA(string, string, string, string, string, string, string, string, string);
    ~PA();

    string getLicenseNumber();
    void setLicenseNumber(string);

    string getSpecialty();
    void setSpecialty(string);

    string DisplayInformation();
};
string PA::DisplayInformation()
{
	string tempString = "";
	tempString = MedicalProfessional::DisplayInformation() + "\n";
	tempString += "License Number: " + getLicenseNumber() + "\n";
	tempString += "Speciality: " + getSpecialty() + "\n";
	return tempString;
}
#pragma once
#include "MedicalProfessional.h"
#include "Nurse.h"
class DoctorGP :
    public MedicalProfessional
{
private:
    string officePhone;
    int patientCount;
    bool boardCertified;
    Nurse myNurse;

public:
    DoctorGP();
    DoctorGP(string, int, bool, Nurse, string, string, string, string, string, string, string);
    ~DoctorGP();

    string getOfficePhone();
    void setOfficePhone(string);  

    int getPatientCount();
    void setPatientCount(int);

    bool getBoardCertified();
    void setBoardCertified(bool);

    Nurse getNurse();

    string DisplayInformation();
};
string DoctorGP::DisplayInformation()
{
	string tempString = "Doctor **************\n";
	tempString += MedicalProfessional::DisplayInformation() + "\n";
	tempString += "Board Certified: ";
	if (getBoardCertified())
	{
		tempString += "Yes\n";
	}
	else
	{
		tempString += "No\n";
	}
	tempString += "Office Phone: " + getOfficePhone() + "\n";
	tempString += "Patient Count: " + to_string(getPatientCount()) + "\n";
	tempString += "Nurse ***************\n";
	tempString += myNurse.DisplayInformation();
	tempString += "*********************\n";
	return tempString;
}
#pragma once
#include "MedicalProfessional.h"
#include"PA.h"
class Surgeon :
    public MedicalProfessional
{
private:
    string officePhone;
    string hospital;
    PA myPA;

public:
    Surgeon();
    Surgeon(string, string, PA, string, string, string, string, string, string, string);
    ~Surgeon();

    string getOfficeNumber();
    void setOfficeNumber(string);

    string getHospital();
    void setHospital(string);

    void setPA(PA);
    string DisplayInformation();

};


It's using classes and arrays, any information would be great.
Last edited on
put it in code tags (<> on the sidebar editor )
and explain what 'trouble' you are having. All we know so far is you are unhappy with it, but not why.
New to this forum so not sure how to set it up with the code tags. when going to compile the code i keep getting "Code Description Project File Line Suppression State
Error LNK2005 "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall MedicalProfessional::DisplayInformation(void)" (?DisplayInformation@MedicalProfessional@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) already defined in DoctorGP.obj Project9 C:\Users\jacks\source\repos\Project9\Project9\Nurse.obj 1"
this as an error code. I have the classes built, but dont have the Source.cpp built for the program itself
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#pragma once
#include<string>
using namespace std;

class MedicalProfessional
{
private:
string firstName;
string lastName;
string address;
string city;
string state;
string zip;
string cellPhone;

public:
MedicalProfessional();
MedicalProfessional(string, string, string, string, string, string, string);
~MedicalProfessional();

string getFirstName();
void setFirstName(string);
string getLastName();
void setLastName(string);
string getAddress();
void setAddress(string);
string getCity();
void setCity(string);
string getState();
void setState(string);
string getZip();
void setZip(string);
string getCellPhone();
void setCellPhone(string);

string DisplayInformation();
};
string MedicalProfessional::DisplayInformation()
{
string tempString = "";
tempString += "Name: " + getFirstName() +
" " + getLastName() + ", " + getAddress() + ", " + getCity()
+ ", " + getState() + ", " + getZip() + "\n";
tempString += "Cell Phone: " + getCellPhone();
return tempString;
}
#pragma once
#include "MedicalProfessional.h"
#include<string>
using namespace std;
class Nurse :
public MedicalProfessional
{
private:
string type;
bool certificationCPR;
public:
Nurse();
Nurse(string, bool, string, string, string, string, string, string, string);
~Nurse();

string getType();
void setType(string);

bool getCertificationCPR();
void setCertificationCPR(bool);

string DisplayInformation();

};
string Nurse::DisplayInformation()
{
string tempString = "";
tempString = MedicalProfessional::DisplayInformation() + "\n";
tempString += "CPR Certified: ";
if (getCertificationCPR())
{
tempString += "Yes\n";
}
else
{
tempString += "No\n";
}
tempString += "Type: " + getType() + "\n";
return tempString;
}
#pragma once
#include "MedicalProfessional.h"
class PA :
public MedicalProfessional
{
private:
string licenseNumber;
string specialty;
public:
PA();
PA(string, string, string, string, string, string, string, string, string);
~PA();

string getLicenseNumber();
void setLicenseNumber(string);

string getSpecialty();
void setSpecialty(string);

string DisplayInformation();
};
string PA::DisplayInformation()
{
string tempString = "";
tempString = MedicalProfessional::DisplayInformation() + "\n";
tempString += "License Number: " + getLicenseNumber() + "\n";
tempString += "Speciality: " + getSpecialty() + "\n";
return tempString;
}
#pragma once
#include "MedicalProfessional.h"
#include "Nurse.h"
class DoctorGP :
public MedicalProfessional
{
private:
string officePhone;
int patientCount;
bool boardCertified;
Nurse myNurse;

public:
DoctorGP();
DoctorGP(string, int, bool, Nurse, string, string, string, string, string, string, string);
~DoctorGP();

string getOfficePhone();
void setOfficePhone(string);

int getPatientCount();
void setPatientCount(int);

bool getBoardCertified();
void setBoardCertified(bool);

Nurse getNurse();

string DisplayInformation();
};
string DoctorGP::DisplayInformation()
{
string tempString = "Doctor **************\n";
tempString += MedicalProfessional::DisplayInformation() + "\n";
tempString += "Board Certified: ";
if (getBoardCertified())
{
tempString += "Yes\n";
}
else
{
tempString += "No\n";
}
tempString += "Office Phone: " + getOfficePhone() + "\n";
tempString += "Patient Count: " + to_string(getPatientCount()) + "\n";
tempString += "Nurse ***************\n";
tempString += myNurse.DisplayInformation();
tempString += "*********************\n";
return tempString;
}
#pragma once
#include "MedicalProfessional.h"
#include"PA.h"
class Surgeon :
public MedicalProfessional
{
private:
string officePhone;
string hospital;
PA myPA;

public:
Surgeon();
Surgeon(string, string, PA, string, string, string, string, string, string, string);
~Surgeon();

string getOfficeNumber();
void setOfficeNumber(string);

string getHospital();
void setHospital(string);

void setPA(PA);
string DisplayInformation();

};
I don't see the issue just reading it and can't get this into my compiler easily right now. I will try again later if someone else has not cracked it. I suspect include guard problem, or the like, not an actual code problem. Double check all your files for proper guards?
I input the code and run the compiler, and i get (Build started...
1>------ Build started: Project: Project9, Configuration: Debug Win32 ------
1>Source.cpp
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========)
But then running the program a get 46 errors all similar to this (Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "public: int __thiscall DoctorGP::getPatientCount(void)" (?getPatientCount@DoctorGP@@QAEHXZ) referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall DoctorGP::DisplayInformation(void)" (?DisplayInformation@DoctorGP@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) Project9 C:\Users\jacks\source\repos\Project9\Project9\DoctorGP.obj 1)
they all have the same error on each class, line 1.
Okay, where did you implement those functions?
I created a class for each. Surgeon, DoctorGP, PA, Nurse, and MedicalProfessional
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once
#include<string>
using namespace std;

class MedicalProfessional
{
private:
	string firstName;
	string lastName;
	string address;
	string city;
	string state;
	string zip;
	string cellPhone;

public:
	MedicalProfessional();
	MedicalProfessional(string, string, string, string, string, string, string);
	~MedicalProfessional();

	string getFirstName();
	void setFirstName(string);
	string getLastName();
	void setLastName(string);
	string getAddress();
	void setAddress(string);
	string getCity();
	void setCity(string);
	string getState();
	void setState(string);
	string getZip();
	void setZip(string);
	string getCellPhone();
	void setCellPhone(string);

	string DisplayInformation();
};
string MedicalProfessional::DisplayInformation()
{
	string tempString = "";
	tempString += "Name: " + getFirstName() +
		" " + getLastName() + ", " + getAddress() + ", " + getCity()
		+ ", " + getState() + ", " + getZip() + "\n";
	tempString += "Cell Phone: " + getCellPhone();
	return tempString;
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once
#include "MedicalProfessional.h"
#include<string>
using namespace std;
class Nurse :
    public MedicalProfessional
{
private:
    string type;
    bool certificationCPR;
public:
    Nurse();
    Nurse(string, bool, string, string, string, string, string, string, string);
    ~Nurse();

    string getType();
    void setType(string);

    bool getCertificationCPR();
    void setCertificationCPR(bool);

    string DisplayInformation();

};
string Nurse::DisplayInformation()
{
	string tempString = "";
	tempString = MedicalProfessional::DisplayInformation() + "\n";
	tempString += "CPR Certified: ";
	if (getCertificationCPR())
	{
		tempString += "Yes\n";
	}
	else
	{
		tempString += "No\n";
	}
	tempString += "Type: " + getType() + "\n";
	return tempString;
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#pragma once
#include "MedicalProfessional.h"
class PA :
    public MedicalProfessional
{
private:
    string licenseNumber;
    string specialty;
public:
    PA();
    PA(string, string, string, string, string, string, string, string, string);
    ~PA();

    string getLicenseNumber();
    void setLicenseNumber(string);

    string getSpecialty();
    void setSpecialty(string);

    string DisplayInformation();
};




string PA::DisplayInformation()
{
    string tempString = "";
    tempString = MedicalProfessional::DisplayInformation() + "\n";
    tempString += "License Number: " + getLicenseNumber() + "\n";
    tempString += "Speciality: " + getSpecialty() + "\n";
    return tempString;
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once
#include "MedicalProfessional.h"
#include "Nurse.h"
class DoctorGP :
    public MedicalProfessional
{
private:
    string officePhone;
    int patientCount;
    bool boardCertified;
    Nurse myNurse;

public:
    DoctorGP();
    DoctorGP(string, int, bool, Nurse, string, string, string, string, string, string, string);
    ~DoctorGP();

    string getOfficePhone();
    void setOfficePhone(string);

    int getPatientCount();
    void setPatientCount(int);

    bool getBoardCertified();
    void setBoardCertified(bool);

    Nurse getNurse();

    string DisplayInformation();
};
string DoctorGP::DisplayInformation()
{
	string tempString = "Doctor **************\n";
	tempString += MedicalProfessional::DisplayInformation() + "\n";
	tempString += "Board Certified: ";
	if (getBoardCertified())
	{
		tempString += "Yes\n";
	}
	else
	{
		tempString += "No\n";
	}
	tempString += "Office Phone: " + getOfficePhone() + "\n";
	tempString += "Patient Count: " + to_string(getPatientCount()) + "\n";
	tempString += "Nurse ***************\n";
	tempString += myNurse.DisplayInformation();
	tempString += "*********************\n";
	return tempString;
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#pragma once
#include "MedicalProfessional.h"
#include"PA.h"
class Surgeon :
    public MedicalProfessional
{
private:
    string officePhone;
    string hospital;
    PA myPA;

public:
    Surgeon();
    Surgeon(string, string, PA, string, string, string, string, string, string, string);
    ~Surgeon();

    string getOfficeNumber();
    void setOfficeNumber(string);

    string getHospital();
    void setHospital(string);

    void setPA(PA);
    string DisplayInformation();

};
Okay so you created the classes, but where did you create all of those functions that were declared within each class?

That's one of the issues I'm running into.
I'm not a coder was a Marine radio operator, I'm just trying to get through these coding classes for school.
So fix it. You declared a bunch of functions but failed to implement them.

By the way you can probably eliminate (for now) most of the functions if you would just use the class variables in your display member functions.

For example your MedicalProfessional class could start with something like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class MedicalProfessional
{
    private:
        string firstName;
        string lastName;
        string address;
        string city;
        string state;
        string zip;
        string cellPhone;

    public:
        MedicalProfessional() = default;
        MedicalProfessional(const std::string& firstName, const std::string& lastName,
                            const std::string& address, const std::string& city,
                            const std::string& zip, const std::string& cellPhone);
        string DisplayInformation();
};

inline string MedicalProfessional::DisplayInformation()
{
    string tempString = "Name: " + firstName +
                  " " + lastName + ", " + address + ", " + city
                  + ", " + state + ", " + zip + "\n";
                  + "Cell Phone: " + cellPhone;
    return tempString;
}


You will still need to implement the constructor. And you really shouldn't be using the using namespace clause inside header files and header files should not contain executable code (with the exception of template classes which you'll find out about later).


By the way you should be compiling early and often. As it is you've made things much more complicated by waiting to compile the program until you have written so much code. If you would have compiled each class and fixed all compile/link errors you wouldn't have so many errors to deal with.
Topic archived. No new replies allowed.