C++ Extracting data from text files

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2008
Posts: 11
Reputation: davidleeis14 is an unknown quantity at this point 
Solved Threads: 0
davidleeis14 davidleeis14 is offline Offline
Newbie Poster

Re: C++ Extracting data from text files

 
0
  #11
Aug 4th, 2008
Thanks for all that code but how would that be used in my program as I have two member types, a full member and a young member type. These member types have there own classes and a derived from a partent Member class.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: C++ Extracting data from text files

 
0
  #12
Aug 4th, 2008
It's exactly C++ battlefield!

Declare class Member as an abstract class (with pure virtual functions), define these virtual functions in FullMember and YoungMember classes, use vector<Member*> in your variant of my PlainDb - that's all. Polymorphism works!..

I suspect that it's a true aim of your (homework?) task.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 11
Reputation: davidleeis14 is an unknown quantity at this point 
Solved Threads: 0
davidleeis14 davidleeis14 is offline Offline
Newbie Poster

Re: C++ Extracting data from text files

 
0
  #13
Aug 4th, 2008
I wonder how you guessed that! Thanks for the help guys.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 401
Reputation: CoolGamer48 is on a distinguished road 
Solved Threads: 40
CoolGamer48's Avatar
CoolGamer48 CoolGamer48 is offline Offline
Posting Pro in Training

Re: C++ Extracting data from text files

 
0
  #14
Aug 4th, 2008
It might not be that simple if you also need to keep track of whether a member is full or young. You would need to output that in some form to your text file, and then as you read the data, create an appropriate object based on whether its a full or young member.
I'm a student. If my statements seem too absolute, feel free to coat them with "In my opinion..." or "I believe...".
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: C++ Extracting data from text files

 
0
  #15
Aug 4th, 2008
Yes, it's (one of) a technical problem with deserializing. Fortunately, there are many ways to simplify its solution. We need an arbiter who make a decision (in the PlainDb::load() from my snippet equivalent): new FullMember() or new YoungMember ...
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 11
Reputation: davidleeis14 is an unknown quantity at this point 
Solved Threads: 0
davidleeis14 davidleeis14 is offline Offline
Newbie Poster

Re: C++ Extracting data from text files

 
0
  #16
Aug 5th, 2008
Are you saying that it would be better to output both member types in one text file?
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 449
Reputation: Agni is a jewel in the rough Agni is a jewel in the rough Agni is a jewel in the rough 
Solved Threads: 70
Sponsor
Agni's Avatar
Agni Agni is offline Offline
Posting Pro in Training

Re: C++ Extracting data from text files

 
0
  #17
Aug 5th, 2008
you could add one more field to the structure which specifies the 'member_type' and write that to your file then when you load the file based on the 'member_type' you can create the correct object type.
thanks
-chandra
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 11
Reputation: davidleeis14 is an unknown quantity at this point 
Solved Threads: 0
davidleeis14 davidleeis14 is offline Offline
Newbie Poster

Re: C++ Extracting data from text files

 
0
  #18
Aug 5th, 2008
Don't shoot me for this, but where do I write the structure for member type (I have two child classes and one parent class that defines the objects) and where do I put "vector<Member*>" and what do I do with it?
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 449
Reputation: Agni is a jewel in the rough Agni is a jewel in the rough Agni is a jewel in the rough 
Solved Threads: 70
Sponsor
Agni's Avatar
Agni Agni is offline Offline
Posting Pro in Training

Re: C++ Extracting data from text files

 
0
  #19
Aug 5th, 2008
you dont need a separate structure for a member_type, use the exisiting structure which coolgamer had suggested and add another field to it.

i think best would be that you try to write some code from whatever you have understood till now and post it, then we can take it from there.
thanks
-chandra
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 11
Reputation: davidleeis14 is an unknown quantity at this point 
Solved Threads: 0
davidleeis14 davidleeis14 is offline Offline
Newbie Poster

Re: C++ Extracting data from text files

 
0
  #20
Aug 5th, 2008
How do you load the data from the txt files into a vector, thats what I can't understand. I have changed my program so that it only uses on text file, but each line of that files starts with either Full Mem or Young Mem depending on the account stored. Also the Young member has 4 pieces of data stored with it wheras the full mem only has three.

I want the program to call up this data so that it can be used in the accounts assciated functions i.e. deposit money, withdraw or calculate the interest etc.
Last edited by davidleeis14; Aug 5th, 2008 at 8:24 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC