#include <iostream>
#include <stdlib.h>
usingnamespace std;
struct a {
string name;
int recordnum;
int age;
int birthdate;
string desc;
};
class b {
private:
int c,d,e;
string f;
public:
b() // Constructor
{
void addpatient();
void editdesc();
}
void addpatient() // here i wanna add full record for patient
{
a add[100];
int r;
cout<<"enter the the record num"<<endl;
cin>>r;
cout<<"enter name"<<endl;
cin>>add[r].name;
cout<<"enter record num"<<endl;
cin>>add[r].recordnum;
cout<<"enterage"<<endl;
cin>>add[r].age;
cout<<"enter birth"<<endl;
cin>>add[r].birthdate;
cout<<"enter desc"<<endl;
cin>>add[r].desc;
}
void editdesc() // here i wanna edit patient descrption (only) already exist
{
a edit[100];
int l;
cout<<"enter the the record num"<<endl;
cin>>l;
cout<<"enter desc"<<endl;
cin>>edit[l].desc;
}
};
int main(){
b g;
g.addpatient();
g.editdesc();
system ("pause");
return 0;
};
it works so i download it in folder my project in a1.cpp then i made another program called a1.h so i can use this in any another program a1.h but i now i get many errors i dont know why!!
maybe guys cant get it so i will explain what i want here
i want same this code in another program like
<iostream.h> it has functions and variables
i want make a1.h works to use this a1 program in another project
like this <a1.h> then i can use its functions an variables
but actually i dont know how :) i just tried but i couldn,t ,i saw my teacher did that but i forget how!
thank you
#include <iostream>
#include <stdlib.h>
usingnamespace std;
struct a {
string name;
int recordnum;
int age;
int birthdate;
string desc;
};
class b {
private:
int c,d,e;
string f;
public:
b() // Constructor
{
void addpatient();
void editdesc();
}
void addpatient() // here i wanna add full record for patient
{
a add[100];
int r;
cout<<"enter the the record num"<<endl;
cin>>r;
cout<<"enter name"<<endl;
cin>>add[r].name;
cout<<"enter record num"<<endl;
cin>>add[r].recordnum;
cout<<"enterage"<<endl;
cin>>add[r].age;
cout<<"enter birth"<<endl;
cin>>add[r].birthdate;
cout<<"enter desc"<<endl;
cin>>add[r].desc;
}
void editdesc() // here i wanna edit patient descrption (only) already exist
{
a edit[100];
int l;
cout<<"enter the the record num"<<endl;
cin>>l;
cout<<"enter desc"<<endl;
cin>>edit[l].desc;
}
};
#include <iostream>
#include <stdlib.h>
usingnamespace std;
struct a {
string name;
int recordnum;
int age;
int birthdate;
string desc;
};
class b {
private:
int c,d,e;
string f;
public:
b(); // Constructor
void addpatient(); // here i wanna add full record for patient
void editdesc(); // here i wanna edit patient descrption (only) already exist
};
#include "a1.h"
b::b() // Constructor
{
void addpatient();
void editdesc();
}
void b::addpatient() // here i wanna add full record for patient
{
a add[100];
int r;
cout<<"enter the the record num"<<endl;
cin>>r;
cout<<"enter name"<<endl;
cin>>add[r].name;
cout<<"enter record num"<<endl;
cin>>add[r].recordnum;
cout<<"enterage"<<endl;
cin>>add[r].age;
cout<<"enter birth"<<endl;
cin>>add[r].birthdate;
cout<<"enter desc"<<endl;
cin>>add[r].desc;
}
void b::editdesc() // here i wanna edit patient descrption (only) already exist
{
a edit[100];
int l;
cout<<"enter the the record num"<<endl;
cin>>l;
cout<<"enter desc"<<endl;
cin>>edit[l].desc;
}
To call it, like so: #include <a1.h> , you need to put this file in the include directory of your compiler. Otherwise, you can use #include "a1.h" and just stick the header in the same directory as your .cpp file.
yeah , i realy dont get all wht you said but i get these things
we shouln,t put int main in .h file
and you shouldn,t do that #include<a1.h> but you you should do this #include"a1.h"
thank you alot brother the program works very well now .