0% found this document useful (0 votes)
10 views1 page

C++ Doctor and Patient Classes Example

The document contains C++ code defining two classes: Doctor and Patient. The Doctor class includes attributes for name and specialty, while the Patient class includes attributes for name and up to two ailments. The main function creates instances of both classes and displays their information.

Uploaded by

tudi098
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

C++ Doctor and Patient Classes Example

The document contains C++ code defining two classes: Doctor and Patient. The Doctor class includes attributes for name and specialty, while the Patient class includes attributes for name and up to two ailments. The main function creates instances of both classes and displays their information.

Uploaded by

tudi098
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#include <iostream>

#include <string>
using namespace std;

class Doctor {
public:
string name;
string specialty;

Doctor(string n, string s) {
name = n;
specialty = s;
}
void display() {
cout << "Doctor: " << name << ", Specialty: " << specialty << endl;
}
};

class Patient {
public:
string name;
string ailment1;
string ailment2;

Patient(string n, string a1, string a2 = ""){


name = n;
ailment1 = a1;
ailment2 = a2;
}
void display() {
cout << "Patient: " << name << ", Ailments: " << ailment1;
if (![Link]()) cout << ", " << ailment2;
cout << endl;
}
};

int main() {
Doctor doctor1("Popescu", "Heart");
Doctor doctor2("Ionescu", "Lung");

Patient patient1("Vasile", "Heart");


Patient patient2("George", "Lung");
Patient patient3("Ion", "Heart", "Lung");

[Link]();
[Link]();

[Link]();
[Link]();
[Link]();

return 0;
}

You might also like