SlideShare a Scribd company logo
1 of 8
Download to read offline
C++ Programming:
So I received help with a code that takes a diabetics name, age, food consumed, and the blood
sugar (before and after) using linked lists and then copies the information to a file. How would I
make this so that the Person class only holds name and age, but then an inherited class Diabetic
takes the reigns and has name+age from Person and then adds the food, and blood sugar results?
Is that even possible with linked lists? And how would I create an option on whether user would
like to copy to a file instead of automatically copying it?
code:
Program code:
#include
#include
#include
using namespace std;
struct Record
{
string name;
int age;
string food;
int after;
int before;
Record *next;
}*head;
class People {
public:
int count=0;
Record* create_node(string,int,string,int,int);
void insert();
void display();
People()
{
head = NULL;
}
};
int main()
{
cout << "patient details" << endl << endl;
head = NULL;
People p;
p.insert();
p.insert();
p.display();
return 0;
}
Record *People::create_node(string nam,int a,string foo,int af,int bef)
{
struct Record *newRecord, *s;
newRecord = new Record;
if (newRecord == NULL)
{
cout<<"Memory not allocated "< name = nam;
newRecord -> age = a;
newRecord -> food = foo;
newRecord -> after = af;
newRecord -> before = bef;
newRecord -> next = NULL;
return newRecord;
}
}
void People::insert()
{
string s_name;
int s_age;
string s_food;
int s_after;
int s_before;
Record *Record_ptr,*newRecord;
ofstream outfile;
outfile.open("Patient.txt");
cout<<"Enter patient details";
cin>>s_name>>s_age>>s_food>>s_after>>s_before;
outfile<next = NULL;
}
else
{
Record_ptr = head;
while(Record_ptr -> next)
Record_ptr = Record_ptr -> next;
Record_ptr -> next = newRecord;
}
outfile.close();
}
void People::display()
{
Record *Display_ptr;
Display_ptr = head;
while(Display_ptr != NULL)
{
cout << Display_ptr -> name << endl;
cout << Display_ptr -> age << endl;
cout << Display_ptr -> food << endl;
cout << Display_ptr -> after << endl;
cout << Display_ptr -> before << endl;
Display_ptr = Display_ptr -> next;
cout << endl;
}
cout<<" Number of patient in file:"<
Solution
#include
#include
#include
#include
#include
#include
class patient
{
public:
char name[20];
char blood_group[5];
int pat_id;
long int phn;
int a;
void patientdata();
void showdata();
};
void patient::patientdata()
{
cout<<"
*****************************************************************************
** ";
cout<<"   tttCreate New Patient Database ";
cout<<"
*****************************************************************************
** ";
cout<<" Enter Patient ID : ";
cin>>pat_id;
cout<<" Enter Patient Name : ";
cin>>name;
cout<<" Enter Patient Blood Group : ";
cin>>blood_group;
fflush(stdin);
cout<<" Enter Patient Phone : ";
cin>>phn;
}
void patient::showdata()
{
cout<<" Patient IDt: "<>a;
char x;
switch (a)
{
case 1:
clrscr();
fstream f;
f.open("patient",ios::in|ios::out|ios::ate|ios::app|ios::binary);
char ans;
obj.patientdata();
f.write((char *)&obj,sizeof(obj));
getch();
cout<<"Do You Want To Continue? y/n :";
ans=getchar();
if(ans=='Y' || ans=='y')
goto z;
else
break;
case 2:
{
cout<<"  ";
fstream f;
f.open("patient",ios::in|ios::out|ios::ate|ios::app|ios::binary);
char ans;
f.seekg(0);
int ctr=0;
while(f.read((char *)&obj,sizeof(obj)) )
{
ctr=ctr+1;
if(ctr==8)
{
getchar();
clrscr();
ctr=0;
}
obj.showdata();
if(f.eof()==1)
{
break;
}
}
f.close();
cout<<"Do You Want To Continue? y/n :";
cin>>ans;
if(ans=='y'|| ans=='Y')
goto z;
else
{
exit(1);
}
}
break;
case 3:
{
clrscr();
fstream f;
patient obj;
char name[20];
char blood_group[5];
long int phn;
int pat_id;
f.open("patient",ios::in|ios::binary);
cout<<" ";
cout<<"
*****************************************************************************
* ";
cout<<" Modify Patient Database  ";
cout<<"
*****************************************************************************
* ";
cout<<" Enter Patient Name :";
cin>>name;
do
{ f.read((char *)&obj,sizeof(obj));
if(f.eof()==1) {break;}
if(strcmp(obj.name,name)==0)
{
cout<<" tPatient Name :"<>name;
cout<<" tEnter Patient ID : ";
cin>>pat_id;
cout<<" tBlood Group : ";
cin>>blood_group;
cout<<" tEnter Patient Phone :";
cin>>phn;
cout<<"  ";
strcpy(obj.name,name);
strcpy(obj.blood_group,blood_group);
obj.a=a;
int l=f.tellg();
f.close();
f.open("patient",ios::out|ios::binary|ios::ate);
f.seekg(l-sizeof(obj));
f.write((char *)&obj,sizeof(obj));
}
}while(f);
f.close();
cout<<"Do You Want To Continue?y/n :";
ans=getchar();
if(ans=='Y'||ans=='y')
{goto z;}
else
break;
}
case 4:
{
clrscr();
fstream f;
patient obj;
char name[20];
char blood_group[5];
long int phn;
int pat_id;
f.open("patient",ios::in|ios::binary);
cout<<" ";
cout<<"
*****************************************************************************
* ";
cout<<" Search Patient Database  ";
cout<<"
*****************************************************************************
* ";
cout<<" Enter Patient Name :";
cin>>name;
do
{ f.read((char *)&obj,sizeof(obj));
if(f.eof()==1) {break;}
if(strcmp(obj.name,name)==0)
{
cout<<" tPatient Name :"<

More Related Content

Similar to C++ ProgrammingSo I received help with a code that takes a diabet.pdf

Hack an ASP .NET website? Hard, but possible!
Hack an ASP .NET website? Hard, but possible! Hack an ASP .NET website? Hard, but possible!
Hack an ASP .NET website? Hard, but possible! Vladimir Kochetkov
 
So I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdfSo I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdfarjuncollection
 
In C++ please- Only solution code- Define a member function PrintAll(.docx
In C++ please- Only solution code-  Define a member function PrintAll(.docxIn C++ please- Only solution code-  Define a member function PrintAll(.docx
In C++ please- Only solution code- Define a member function PrintAll(.docxlucilabevin
 
project report in C++ programming and SQL
project report in C++ programming and SQLproject report in C++ programming and SQL
project report in C++ programming and SQLvikram mahendra
 
#include iostream #include cstring #include vector #i.pdf
 #include iostream #include cstring #include vector #i.pdf #include iostream #include cstring #include vector #i.pdf
#include iostream #include cstring #include vector #i.pdfanandatalapatra
 
File handling complete programs in c++
File handling complete programs in c++File handling complete programs in c++
File handling complete programs in c++zain ul hassan
 
What's new in C# 6 - NetPonto Porto 20160116
What's new in C# 6  - NetPonto Porto 20160116What's new in C# 6  - NetPonto Porto 20160116
What's new in C# 6 - NetPonto Porto 20160116Paulo Morgado
 
Rewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdfRewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdfalphaagenciesindia
 
C++ Program to Implement Doubly Linked List #includei.pdf
  C++ Program to Implement Doubly Linked List  #includei.pdf  C++ Program to Implement Doubly Linked List  #includei.pdf
C++ Program to Implement Doubly Linked List #includei.pdfLalkamal2
 
Micro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateMicro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateKiev ALT.NET
 
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdfC++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdfaassecuritysystem
 
Leap Ahead with Redis 6.2
Leap Ahead with Redis 6.2Leap Ahead with Redis 6.2
Leap Ahead with Redis 6.2VMware Tanzu
 
C++ Course - Lesson 3
C++ Course - Lesson 3C++ Course - Lesson 3
C++ Course - Lesson 3Mohamed Ahmed
 
Kirti Kumawat, BCA Third Year
Kirti Kumawat, BCA Third YearKirti Kumawat, BCA Third Year
Kirti Kumawat, BCA Third Yeardezyneecole
 
Hospital management project_BY RITIKA SAHU.
Hospital management project_BY RITIKA SAHU.Hospital management project_BY RITIKA SAHU.
Hospital management project_BY RITIKA SAHU.Ritika sahu
 
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docxINTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docxnormanibarber20063
 

Similar to C++ ProgrammingSo I received help with a code that takes a diabet.pdf (20)

Hack an ASP .NET website? Hard, but possible!
Hack an ASP .NET website? Hard, but possible! Hack an ASP .NET website? Hard, but possible!
Hack an ASP .NET website? Hard, but possible!
 
So I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdfSo I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdf
 
OOPS 22-23 (1).pptx
OOPS 22-23 (1).pptxOOPS 22-23 (1).pptx
OOPS 22-23 (1).pptx
 
Oops presentation
Oops presentationOops presentation
Oops presentation
 
In C++ please- Only solution code- Define a member function PrintAll(.docx
In C++ please- Only solution code-  Define a member function PrintAll(.docxIn C++ please- Only solution code-  Define a member function PrintAll(.docx
In C++ please- Only solution code- Define a member function PrintAll(.docx
 
project report in C++ programming and SQL
project report in C++ programming and SQLproject report in C++ programming and SQL
project report in C++ programming and SQL
 
C++ L09-Classes Part2
C++ L09-Classes Part2C++ L09-Classes Part2
C++ L09-Classes Part2
 
#include iostream #include cstring #include vector #i.pdf
 #include iostream #include cstring #include vector #i.pdf #include iostream #include cstring #include vector #i.pdf
#include iostream #include cstring #include vector #i.pdf
 
File handling complete programs in c++
File handling complete programs in c++File handling complete programs in c++
File handling complete programs in c++
 
What's new in C# 6 - NetPonto Porto 20160116
What's new in C# 6  - NetPonto Porto 20160116What's new in C# 6  - NetPonto Porto 20160116
What's new in C# 6 - NetPonto Porto 20160116
 
Rewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdfRewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdf
 
C++ Program to Implement Doubly Linked List #includei.pdf
  C++ Program to Implement Doubly Linked List  #includei.pdf  C++ Program to Implement Doubly Linked List  #includei.pdf
C++ Program to Implement Doubly Linked List #includei.pdf
 
Micro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateMicro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicate
 
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdfC++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
 
Leap Ahead with Redis 6.2
Leap Ahead with Redis 6.2Leap Ahead with Redis 6.2
Leap Ahead with Redis 6.2
 
C++ Course - Lesson 3
C++ Course - Lesson 3C++ Course - Lesson 3
C++ Course - Lesson 3
 
Ch8 file processing
Ch8 file processingCh8 file processing
Ch8 file processing
 
Kirti Kumawat, BCA Third Year
Kirti Kumawat, BCA Third YearKirti Kumawat, BCA Third Year
Kirti Kumawat, BCA Third Year
 
Hospital management project_BY RITIKA SAHU.
Hospital management project_BY RITIKA SAHU.Hospital management project_BY RITIKA SAHU.
Hospital management project_BY RITIKA SAHU.
 
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docxINTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
 

More from fathimafancy

Write the program segment necessary to Test the C flag. i. If the .pdf
Write the program segment necessary to  Test the C flag.  i. If the .pdfWrite the program segment necessary to  Test the C flag.  i. If the .pdf
Write the program segment necessary to Test the C flag. i. If the .pdffathimafancy
 
Why must Group IV be treated with (NH4)2CO3 in basic solution What .pdf
Why must Group IV be treated with (NH4)2CO3 in basic solution What .pdfWhy must Group IV be treated with (NH4)2CO3 in basic solution What .pdf
Why must Group IV be treated with (NH4)2CO3 in basic solution What .pdffathimafancy
 
what is IOT what us SolutionAns. IOT stands for Internet of Th.pdf
what is IOT what us SolutionAns. IOT stands for Internet of Th.pdfwhat is IOT what us SolutionAns. IOT stands for Internet of Th.pdf
what is IOT what us SolutionAns. IOT stands for Internet of Th.pdffathimafancy
 
What is the difference between a BSS and a ESSSolutionBSS sta.pdf
What is the difference between a BSS and a ESSSolutionBSS sta.pdfWhat is the difference between a BSS and a ESSSolutionBSS sta.pdf
What is the difference between a BSS and a ESSSolutionBSS sta.pdffathimafancy
 
What is the role of capsid and nucleocapsid proteins during the life.pdf
What is the role of capsid and nucleocapsid proteins during the life.pdfWhat is the role of capsid and nucleocapsid proteins during the life.pdf
What is the role of capsid and nucleocapsid proteins during the life.pdffathimafancy
 
What distinguish between managerial and financial accounting as to (.pdf
What distinguish between managerial and financial accounting as to (.pdfWhat distinguish between managerial and financial accounting as to (.pdf
What distinguish between managerial and financial accounting as to (.pdffathimafancy
 
There is a lack of spirituality in a person that cheats because they.pdf
There is a lack of spirituality in a person that cheats because they.pdfThere is a lack of spirituality in a person that cheats because they.pdf
There is a lack of spirituality in a person that cheats because they.pdffathimafancy
 
select the answer a general search engine differs from a subject di.pdf
select the answer a general search engine differs from a subject di.pdfselect the answer a general search engine differs from a subject di.pdf
select the answer a general search engine differs from a subject di.pdffathimafancy
 
State briefly what functions an Engineering Services Department in a.pdf
State briefly what functions an Engineering Services Department in a.pdfState briefly what functions an Engineering Services Department in a.pdf
State briefly what functions an Engineering Services Department in a.pdffathimafancy
 
Satellites in geosynchronous orbit have the desirable property of re.pdf
Satellites in geosynchronous orbit have the desirable property of re.pdfSatellites in geosynchronous orbit have the desirable property of re.pdf
Satellites in geosynchronous orbit have the desirable property of re.pdffathimafancy
 
Research and discuss an incident where it was discovered that a Remo.pdf
Research and discuss an incident where it was discovered that a Remo.pdfResearch and discuss an incident where it was discovered that a Remo.pdf
Research and discuss an incident where it was discovered that a Remo.pdffathimafancy
 
Please review the attached casescenario. You are Bill. Feel free to.pdf
Please review the attached casescenario. You are Bill. Feel free to.pdfPlease review the attached casescenario. You are Bill. Feel free to.pdf
Please review the attached casescenario. You are Bill. Feel free to.pdffathimafancy
 
Please make sure it works Ive been struggling with this and so far.pdf
Please make sure it works Ive been struggling with this and so far.pdfPlease make sure it works Ive been struggling with this and so far.pdf
Please make sure it works Ive been struggling with this and so far.pdffathimafancy
 
Please explain the physiological mechanism for enlarged lymph nodes..pdf
Please explain the physiological mechanism for enlarged lymph nodes..pdfPlease explain the physiological mechanism for enlarged lymph nodes..pdf
Please explain the physiological mechanism for enlarged lymph nodes..pdffathimafancy
 
multiple choiceAssuming that the probability for each shot is .pdf
multiple choiceAssuming that the probability for each shot is .pdfmultiple choiceAssuming that the probability for each shot is .pdf
multiple choiceAssuming that the probability for each shot is .pdffathimafancy
 
Mathematical Statistics.....Could answer be typed (is there any link.pdf
Mathematical Statistics.....Could answer be typed (is there any link.pdfMathematical Statistics.....Could answer be typed (is there any link.pdf
Mathematical Statistics.....Could answer be typed (is there any link.pdffathimafancy
 
Modify the Stack class given in the book in order for it to store do.pdf
Modify the Stack class given in the book in order for it to store do.pdfModify the Stack class given in the book in order for it to store do.pdf
Modify the Stack class given in the book in order for it to store do.pdffathimafancy
 
Let V be a finite dimensional vector space over F with T element (V,.pdf
Let V be a finite dimensional vector space over F with T element  (V,.pdfLet V be a finite dimensional vector space over F with T element  (V,.pdf
Let V be a finite dimensional vector space over F with T element (V,.pdffathimafancy
 
Java programI made this Account.java below. Using the attached cod.pdf
Java programI made this Account.java below. Using the attached cod.pdfJava programI made this Account.java below. Using the attached cod.pdf
Java programI made this Account.java below. Using the attached cod.pdffathimafancy
 
In the follwoing double bond hydration reaction styrene + water (so.pdf
In the follwoing double bond hydration reaction styrene + water (so.pdfIn the follwoing double bond hydration reaction styrene + water (so.pdf
In the follwoing double bond hydration reaction styrene + water (so.pdffathimafancy
 

More from fathimafancy (20)

Write the program segment necessary to Test the C flag. i. If the .pdf
Write the program segment necessary to  Test the C flag.  i. If the .pdfWrite the program segment necessary to  Test the C flag.  i. If the .pdf
Write the program segment necessary to Test the C flag. i. If the .pdf
 
Why must Group IV be treated with (NH4)2CO3 in basic solution What .pdf
Why must Group IV be treated with (NH4)2CO3 in basic solution What .pdfWhy must Group IV be treated with (NH4)2CO3 in basic solution What .pdf
Why must Group IV be treated with (NH4)2CO3 in basic solution What .pdf
 
what is IOT what us SolutionAns. IOT stands for Internet of Th.pdf
what is IOT what us SolutionAns. IOT stands for Internet of Th.pdfwhat is IOT what us SolutionAns. IOT stands for Internet of Th.pdf
what is IOT what us SolutionAns. IOT stands for Internet of Th.pdf
 
What is the difference between a BSS and a ESSSolutionBSS sta.pdf
What is the difference between a BSS and a ESSSolutionBSS sta.pdfWhat is the difference between a BSS and a ESSSolutionBSS sta.pdf
What is the difference between a BSS and a ESSSolutionBSS sta.pdf
 
What is the role of capsid and nucleocapsid proteins during the life.pdf
What is the role of capsid and nucleocapsid proteins during the life.pdfWhat is the role of capsid and nucleocapsid proteins during the life.pdf
What is the role of capsid and nucleocapsid proteins during the life.pdf
 
What distinguish between managerial and financial accounting as to (.pdf
What distinguish between managerial and financial accounting as to (.pdfWhat distinguish between managerial and financial accounting as to (.pdf
What distinguish between managerial and financial accounting as to (.pdf
 
There is a lack of spirituality in a person that cheats because they.pdf
There is a lack of spirituality in a person that cheats because they.pdfThere is a lack of spirituality in a person that cheats because they.pdf
There is a lack of spirituality in a person that cheats because they.pdf
 
select the answer a general search engine differs from a subject di.pdf
select the answer a general search engine differs from a subject di.pdfselect the answer a general search engine differs from a subject di.pdf
select the answer a general search engine differs from a subject di.pdf
 
State briefly what functions an Engineering Services Department in a.pdf
State briefly what functions an Engineering Services Department in a.pdfState briefly what functions an Engineering Services Department in a.pdf
State briefly what functions an Engineering Services Department in a.pdf
 
Satellites in geosynchronous orbit have the desirable property of re.pdf
Satellites in geosynchronous orbit have the desirable property of re.pdfSatellites in geosynchronous orbit have the desirable property of re.pdf
Satellites in geosynchronous orbit have the desirable property of re.pdf
 
Research and discuss an incident where it was discovered that a Remo.pdf
Research and discuss an incident where it was discovered that a Remo.pdfResearch and discuss an incident where it was discovered that a Remo.pdf
Research and discuss an incident where it was discovered that a Remo.pdf
 
Please review the attached casescenario. You are Bill. Feel free to.pdf
Please review the attached casescenario. You are Bill. Feel free to.pdfPlease review the attached casescenario. You are Bill. Feel free to.pdf
Please review the attached casescenario. You are Bill. Feel free to.pdf
 
Please make sure it works Ive been struggling with this and so far.pdf
Please make sure it works Ive been struggling with this and so far.pdfPlease make sure it works Ive been struggling with this and so far.pdf
Please make sure it works Ive been struggling with this and so far.pdf
 
Please explain the physiological mechanism for enlarged lymph nodes..pdf
Please explain the physiological mechanism for enlarged lymph nodes..pdfPlease explain the physiological mechanism for enlarged lymph nodes..pdf
Please explain the physiological mechanism for enlarged lymph nodes..pdf
 
multiple choiceAssuming that the probability for each shot is .pdf
multiple choiceAssuming that the probability for each shot is .pdfmultiple choiceAssuming that the probability for each shot is .pdf
multiple choiceAssuming that the probability for each shot is .pdf
 
Mathematical Statistics.....Could answer be typed (is there any link.pdf
Mathematical Statistics.....Could answer be typed (is there any link.pdfMathematical Statistics.....Could answer be typed (is there any link.pdf
Mathematical Statistics.....Could answer be typed (is there any link.pdf
 
Modify the Stack class given in the book in order for it to store do.pdf
Modify the Stack class given in the book in order for it to store do.pdfModify the Stack class given in the book in order for it to store do.pdf
Modify the Stack class given in the book in order for it to store do.pdf
 
Let V be a finite dimensional vector space over F with T element (V,.pdf
Let V be a finite dimensional vector space over F with T element  (V,.pdfLet V be a finite dimensional vector space over F with T element  (V,.pdf
Let V be a finite dimensional vector space over F with T element (V,.pdf
 
Java programI made this Account.java below. Using the attached cod.pdf
Java programI made this Account.java below. Using the attached cod.pdfJava programI made this Account.java below. Using the attached cod.pdf
Java programI made this Account.java below. Using the attached cod.pdf
 
In the follwoing double bond hydration reaction styrene + water (so.pdf
In the follwoing double bond hydration reaction styrene + water (so.pdfIn the follwoing double bond hydration reaction styrene + water (so.pdf
In the follwoing double bond hydration reaction styrene + water (so.pdf
 

Recently uploaded

SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 

Recently uploaded (20)

SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 

C++ ProgrammingSo I received help with a code that takes a diabet.pdf

  • 1. C++ Programming: So I received help with a code that takes a diabetics name, age, food consumed, and the blood sugar (before and after) using linked lists and then copies the information to a file. How would I make this so that the Person class only holds name and age, but then an inherited class Diabetic takes the reigns and has name+age from Person and then adds the food, and blood sugar results? Is that even possible with linked lists? And how would I create an option on whether user would like to copy to a file instead of automatically copying it? code: Program code: #include #include #include using namespace std; struct Record { string name; int age; string food; int after; int before; Record *next; }*head; class People { public: int count=0; Record* create_node(string,int,string,int,int); void insert(); void display(); People() { head = NULL; } }; int main()
  • 2. { cout << "patient details" << endl << endl; head = NULL; People p; p.insert(); p.insert(); p.display(); return 0; } Record *People::create_node(string nam,int a,string foo,int af,int bef) { struct Record *newRecord, *s; newRecord = new Record; if (newRecord == NULL) { cout<<"Memory not allocated "< name = nam; newRecord -> age = a; newRecord -> food = foo; newRecord -> after = af; newRecord -> before = bef; newRecord -> next = NULL; return newRecord; } } void People::insert() { string s_name; int s_age; string s_food; int s_after; int s_before; Record *Record_ptr,*newRecord; ofstream outfile; outfile.open("Patient.txt");
  • 3. cout<<"Enter patient details"; cin>>s_name>>s_age>>s_food>>s_after>>s_before; outfile<next = NULL; } else { Record_ptr = head; while(Record_ptr -> next) Record_ptr = Record_ptr -> next; Record_ptr -> next = newRecord; } outfile.close(); } void People::display() { Record *Display_ptr; Display_ptr = head; while(Display_ptr != NULL) { cout << Display_ptr -> name << endl; cout << Display_ptr -> age << endl; cout << Display_ptr -> food << endl; cout << Display_ptr -> after << endl; cout << Display_ptr -> before << endl; Display_ptr = Display_ptr -> next; cout << endl; } cout<<" Number of patient in file:"< Solution #include #include
  • 4. #include #include #include #include class patient { public: char name[20]; char blood_group[5]; int pat_id; long int phn; int a; void patientdata(); void showdata(); }; void patient::patientdata() { cout<<" ***************************************************************************** ** "; cout<<" tttCreate New Patient Database "; cout<<" ***************************************************************************** ** "; cout<<" Enter Patient ID : "; cin>>pat_id; cout<<" Enter Patient Name : "; cin>>name; cout<<" Enter Patient Blood Group : "; cin>>blood_group; fflush(stdin); cout<<" Enter Patient Phone : "; cin>>phn; } void patient::showdata() {
  • 5. cout<<" Patient IDt: "<>a; char x; switch (a) { case 1: clrscr(); fstream f; f.open("patient",ios::in|ios::out|ios::ate|ios::app|ios::binary); char ans; obj.patientdata(); f.write((char *)&obj,sizeof(obj)); getch(); cout<<"Do You Want To Continue? y/n :"; ans=getchar(); if(ans=='Y' || ans=='y') goto z; else break; case 2: { cout<<" "; fstream f; f.open("patient",ios::in|ios::out|ios::ate|ios::app|ios::binary); char ans; f.seekg(0); int ctr=0; while(f.read((char *)&obj,sizeof(obj)) ) { ctr=ctr+1; if(ctr==8) { getchar(); clrscr(); ctr=0; } obj.showdata();
  • 6. if(f.eof()==1) { break; } } f.close(); cout<<"Do You Want To Continue? y/n :"; cin>>ans; if(ans=='y'|| ans=='Y') goto z; else { exit(1); } } break; case 3: { clrscr(); fstream f; patient obj; char name[20]; char blood_group[5]; long int phn; int pat_id; f.open("patient",ios::in|ios::binary); cout<<" "; cout<<" ***************************************************************************** * "; cout<<" Modify Patient Database "; cout<<" ***************************************************************************** * "; cout<<" Enter Patient Name :"; cin>>name;
  • 7. do { f.read((char *)&obj,sizeof(obj)); if(f.eof()==1) {break;} if(strcmp(obj.name,name)==0) { cout<<" tPatient Name :"<>name; cout<<" tEnter Patient ID : "; cin>>pat_id; cout<<" tBlood Group : "; cin>>blood_group; cout<<" tEnter Patient Phone :"; cin>>phn; cout<<" "; strcpy(obj.name,name); strcpy(obj.blood_group,blood_group); obj.a=a; int l=f.tellg(); f.close(); f.open("patient",ios::out|ios::binary|ios::ate); f.seekg(l-sizeof(obj)); f.write((char *)&obj,sizeof(obj)); } }while(f); f.close(); cout<<"Do You Want To Continue?y/n :"; ans=getchar(); if(ans=='Y'||ans=='y') {goto z;} else break; } case 4: { clrscr(); fstream f; patient obj;
  • 8. char name[20]; char blood_group[5]; long int phn; int pat_id; f.open("patient",ios::in|ios::binary); cout<<" "; cout<<" ***************************************************************************** * "; cout<<" Search Patient Database "; cout<<" ***************************************************************************** * "; cout<<" Enter Patient Name :"; cin>>name; do { f.read((char *)&obj,sizeof(obj)); if(f.eof()==1) {break;} if(strcmp(obj.name,name)==0) { cout<<" tPatient Name :"<