does anyone have any idea how should we use a function ...that will perform the
same activity for the two diffrent classes...
i have give my problem below...
=====================================
class person
{
char nam[10];
int age;
};
class employ : person
{
char e_id;
public:
void get();
void put();
};
class customer : person
{
char p_id;
public:
void get();
void put();
};
void read(fstream &f,<pointer to class>)
{
saves data to file
}
int main()
{
customer c;
customer * c1;
employ e;
employ * e1;
fstream c,e;
c.open("cus.txt",ios::in);
read(&c,custoemer * c1);
c.close();
e.open("emp.txt",ios::in);
read(&e,employ * e1);
return 0;
}
==========================
now i want to make a read function that will read data form user using get
member function ....and store to the file..
but this same function will use in saving the employ and customer data...
does any trick how can we make this function acessible to both class and
perfrom same operation withoout writing this function twice...
does this possible....
plz help me on solving this problem..