Hello, What you need to do is write a function into the class. your person will read and write it's data, mark it as virtual. then from employee you can do something like: person::read(stream) person::write(stream) etc and then below that read in and write the data for that specific class. So your building off the inheritance.
Thanks, Tyler Littlefield http://tds-solutions.net Twitter: sorressean On Mar 22, 2010, at 10:51 AM, Jalpan wrote: > 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.. > > ------------------------------------ To unsubscribe, send a blank message to <mailto:c-prog-unsubscr...@yahoogroups.com>.Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/c-prog/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/c-prog/join (Yahoo! ID required) <*> To change settings via email: c-prog-dig...@yahoogroups.com c-prog-fullfeatu...@yahoogroups.com <*> To unsubscribe from this group, send an email to: c-prog-unsubscr...@yahoogroups.com <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/