I'm attempting to create an application to work with a fluid database
of people. I'm doing this in a command line, text-based manner. I need
to know two things: 1) How do I save data, perhaps a group of objects
and their memebers or a few lines of text? and 2) Is there any way to
automate object construction? I'm thinking that I can create a vector
or something similar to handle the number of people, is there a way
for me to write a function that will create a default object for each
of these people?
Any answers or directions to answers would be greatly appreciated. 4 1651
"Jerivix Entadi" <je*****@hotmail.com> wrote in message
news:86*************************@posting.google.co m... I'm attempting to create an application to work with a fluid database of people. I'm doing this in a command line, text-based manner. I need to know two things: 1) How do I save data, perhaps a group of objects and their memebers or a few lines of text?
It's up to you how you save the data. I think you're asking about whether
you should save as binary data or text. This really depends on what you want
to do with the data. Binary would be the traditional approach but these days
XML should be considered since it will enable your data to be processed by
all the XML parsers that are out there.
and 2) Is there any way to automate object construction? I'm thinking that I can create a vector or something similar to handle the number of people, is there a way for me to write a function that will create a default object for each of these people?
I don't really understand this question either. You can write any
constructor you like, does that count as automatic object construction? Any answers or directions to answers would be greatly appreciated.
I think a bit more detail in the question will get you more help.
john
"John Harrison" <jo*************@hotmail.com> wrote in message news:<c1*************@ID-196037.news.uni-berlin.de>... "Jerivix Entadi" <je*****@hotmail.com> wrote in message news:86*************************@posting.google.co m... I'm attempting to create an application to work with a fluid database of people. I'm doing this in a command line, text-based manner. I need to know two things: 1) How do I save data, perhaps a group of objects and their memebers or a few lines of text?
It's up to you how you save the data. I think you're asking about whether you should save as binary data or text. This really depends on what you want to do with the data. Binary would be the traditional approach but these days XML should be considered since it will enable your data to be processed by all the XML parsers that are out there.
and 2) Is there any way to automate object construction? I'm thinking that I can create a vector or something similar to handle the number of people, is there a way for me to write a function that will create a default object for each of these people?
I don't really understand this question either. You can write any constructor you like, does that count as automatic object construction?
Any answers or directions to answers would be greatly appreciated.
I think a bit more detail in the question will get you more help.
john
Let me carify a bit. I don't know how to even save as binary data or
XML. I've done a bit of experimentation with saving single lines of
text, but past that I really don't know much.
As far as object creation goes, I'm not worried about the constructor
itself, but rather defining the objects in the first place. Is there
any way to write soemthing that will create the objects for me?
In other words, if I have a Class People, and the user inputs "Betty",
can I then pass "Betty" into a function that will create an object for
Betty and let the constructor etc. take it from there?
"Jerivix Entadi" <je*****@hotmail.com> wrote in message
news:86**************************@posting.google.c om... "John Harrison" <jo*************@hotmail.com> wrote in message
news:<c1*************@ID-196037.news.uni-berlin.de>... "Jerivix Entadi" <je*****@hotmail.com> wrote in message news:86*************************@posting.google.co m... I'm attempting to create an application to work with a fluid database of people. I'm doing this in a command line, text-based manner. I need to know two things: 1) How do I save data, perhaps a group of objects and their memebers or a few lines of text?
It's up to you how you save the data. I think you're asking about
whether you should save as binary data or text. This really depends on what you
want to do with the data. Binary would be the traditional approach but these
days XML should be considered since it will enable your data to be processed
by all the XML parsers that are out there.
and 2) Is there any way to automate object construction? I'm thinking that I can create a vector or something similar to handle the number of people, is there a way for me to write a function that will create a default object for each of these people?
I don't really understand this question either. You can write any constructor you like, does that count as automatic object construction?
Any answers or directions to answers would be greatly appreciated.
I think a bit more detail in the question will get you more help.
john
Let me carify a bit. I don't know how to even save as binary data or XML. I've done a bit of experimentation with saving single lines of text, but past that I really don't know much.
File I/O (binary or text) is done in C++ with the iostream library. That's
rather a big topic to cover in a newsgroup post. As far as object creation goes, I'm not worried about the constructor itself, but rather defining the objects in the first place. Is there any way to write soemthing that will create the objects for me?
I'm sure there is.
In other words, if I have a Class People, and the user inputs "Betty", can I then pass "Betty" into a function that will create an object for Betty and let the constructor etc. take it from there?
Seems a bit confused, you say 'create an object for Betty and let the
constructor etc. take it from there' but it is the constructors job to
create objects, nothing else's.
You can certainly write a function that given a persons name will create an
object for that person.
Person create_person(std::string name)
{
// create the person here
}
Of course you have to fill in the part indicated by the comment 'create the
person here'
But I sense you are asking for something more, since the above code is
completely straightforward. Unfortunately I'm still not sure what that is.
john
Jerivix Entadi wrote: "John Harrison" <jo*************@hotmail.com> wrote in message news:<c1*************@ID-196037.news.uni-berlin.de>...
"Jerivix Entadi" <je*****@hotmail.com> wrote in message Let me carify a bit. I don't know how to even save as binary data or XML. I've done a bit of experimentation with saving single lines of text, but past that I really don't know much.
As far as object creation goes, I'm not worried about the constructor itself, but rather defining the objects in the first place. Is there any way to write soemthing that will create the objects for me?
In other words, if I have a Class People, and the user inputs "Betty", can I then pass "Betty" into a function that will create an object for Betty and let the constructor etc. take it from there?
Search the newsgroups and web for "Design Pattern Factory".
This is a pattern used for creating instances given an indentifier
of some sort.
As for writing objects, the trick is to have each object provide
a method (or overload an existing operator) to write (and read)
each member. If the member is not a simple type, then it should
have read and write methods too.
The methods to use are the I/O streams. Also search the newsgroups
and web for "Serialization OR permanent C++". See the C++ FAQ: http://www.parashift.com/c++-faq-lit...alization.html
One should always research the FAQ and search the newsgroups
(as well as the web) before posting. You can search for
"Thomas Matthews binary write" for some replies I've posted.
{Although I have improved the code a bit since then.}
--
Thomas Matthews
C++ newsgroup welcome message: http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq: http://www.raos.demon.uk/acllc-c++/faq.html
Other sites: http://www.josuttis.com -- C++ STL Library book This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jacob H |
last post by:
Hello list...
I'm developing an adventure game in Python (which of course is lots of
fun). One of the features is the ability to save games and restore the
saves later. I'm using the pickle...
|
by: Dan Avni |
last post by:
I have a site that has been working for a few years now. the web site
is using a DB Access DLL written in VB. the DB's connection string is
passed to the DLL using the COM+ enable object...
|
by: Jim Williams |
last post by:
**** Post for FREE via your newsreader at post.usenet.com ****
I'm working on a 3d engine system.
I need to save/load data in the systems objects to/from XML files.
When I say objects, I mean...
|
by: Tim |
last post by:
Please advise if you can.
Presumably initialisation of members in member initialisation lists is
perfomed by 'C' run-time startup. If the CRT was never started-up would
those members be garbage?...
|
by: Matthias S. |
last post by:
Hi,
I have to write an application which extensively uses an SQL Database.
For a simple example say I have the following tables with the
appropriate fields.
1. Company (ID, Name,...
|
by: theo |
last post by:
Program flow...load file,then extract the xml text tags from the
file,then the number of
Xml tags retrieved from the file determines the number of dropdownlist
controls
instanciated in the...
|
by: DwC |
last post by:
Hi,
We have a ms access database that we will be using to develop a website
which would have fairly low usage levels.
We have some experience with windows apps but not so much with asp.net...
|
by: Peter Duniho |
last post by:
I've been learning about mechanisms .NET offers to export data. The
initial goal is to see what sorts of ways are available to save an
application's state (document, internal database, whatever). ...
|
by: Alf P. Steinbach |
last post by:
I once suggested in that SomeOne Else(TM) should propose
a string value class that accepted literals and char pointers and so on,
with possible custom deleter, and in case of literal strings just...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |