I taught everything I knew about C++ (just above zero) to my programming buddy Shadow.
I don't think he has programmed in C++ before
but soon we had hacked the below program together
It writes an object to a file
but we can not seem to read it in as an object?

any help welcome

The idea is to eventually marry this with other work
on pbase which we started some time ago

Gosh that's a valiant attempt - but in order to write a database of Person objects and store them in a list, you really could make more use of the STL and its very useful iterator classes rather than attempting to do stuff in the old-fashioned slow way using char * etc. STL <string> is also much less error-prone than char *. Confirmed by Bjarne Stroustrup, the creator of C++

Yes, I know that kernel space specialists frown on using C++ inside the kernel itself, but in user space it is a god-send for stuff like hacking together databases.

For storing the Person list, I would go for an STL <list> rather than the <vector> as used here. <list> while maybe being a tad less efficient in theory, is more robust in practice than the likes of <vector>

//loop through the personList until you find what you are looking for:

for(;li !=personList.end();i++)
{
//your search code goes here
}

You could use serialisation to store you objects to hard disk. This is really the best way to do it, but for this relatively simple structure, a text file containing lines of text strings is maybe the best compromise here.

The main menu would be better implemented using the switch statement- again less error-prone.

I'll try to cobble some code together at the weekend. In the meantime, read up on the above techniques in say Deitel and Deitel._________________Life is too short to spend it in front of a computer

Thanks Jack
Appreciate very much the comments.
We (Shadow + Lobster making tea) are very grateful.
Basically 80% of the time is spent looking for samples on the web, which then somehow
- only his third day programming in C++ Shadow manages to tweak, modify and improve . . .

We may well go from vector to list
- we did consider using 'map' but dropped that_________________YinYana AI Buddhism

// todo:
// create a file controller class that saves and loads data at program startup
// best place for loading data is the constructor for a main program object
// create a main database class that holds a list of contacts. Use an STL list<Contact> object for this
// code the database search function (using a list<Contact>::iterator)
// create a user menu

The -g option for has nothing to do with grouping the files to be compiled.

The -g option for g++ tells the compiler to build an executable that contains/includes degugging information. This is necessary in case you need to run the GNU debugger called GDB on your source code in the event of having bugs that are difficult to track down.

Once the final version of the program has been built and tested, you can then recompile the project without the -g option and thereby have a smaller executable - i.e. without the superfluous degugging information._________________Life is too short to spend it in front of a computer

The debugger is only of use in certain circumstances. You need to learn to use the debugger in conjunction with setting watch expressions as well.

There a several good tools available in Puppy that can help. There is a version of Emacs for Puppy available as a pet package somewhere in the forum. This allows you to edit your code and debug it in the same window.

Not sure about Geany - I don't think it can do that.
Other tools are Codeblocks and Netbeans (needs Java though).

There is also an sfs for Anjuta as well that would be suitable_________________Life is too short to spend it in front of a computer

I've just been looking at that original C++ code you posted here.
After I added #include <stdlib.h> it compiled fine.

Tried adding a few records and that seemed to work OK - but when I tried to do a search, it bombed straight out as if it was unable to access the file properly.

On studying that code, whoever wrote it. has used the in.Read() way of doing things that I have never used much in the past. I have a feeling that this function cannot retrieve type information - i.e. only data information using this method. This would certainly make it crash. Would be an interesting task to fix this, but this would mean having to alter the program somewhat.

I'll play with this original code some more and also enhance the program to do searching etc. using a purely STL method as originally suggested.

Keep going with it.

Jack_________________Life is too short to spend it in front of a computerLast edited by tronkel on Tue 13 Oct 2009, 16:12; edited 1 time in total

I added the 'LXRAD GUI' from the puppy package manager in 4.3.1 release cndidate. When I looked at this previously it was completely unstable but may have been improved/recompiled. Anyway that seems sufficient to what we may need in the future. _________________YinYana AI Buddhism

I added the 'LXRAD GUI' from the puppy package manager in 4.3.1 release cndidate. When I looked at this previously it was completely unstable but may have been improved/recompiled. Anyway that seems sufficient to what we may need in the future.

Nah, it's the same old Lxrad PET package. I haven't looked at it since I did so originally. As I recall, it had bugs.

The author stated that he was bewildered by GTK libs and was going to move Lxrad to using Wxwidgets, but I don't know if that ever happened, or even if he did anything more on the Lxrad project._________________http://bkhome.org/news/

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum