Re: [C++] Help with a Database for User Defined Classes

From: Chris \( Val \) (chrisval_at_bigpond.com.au)
Date: 12/21/04


Date: Tue, 21 Dec 2004 15:29:18 +1100


"entropy123" <email_entropy123@yahoo.com> wrote in message
news:1103577782.251492.216930@c13g2000cwb.googlegroups.com...
| Hi All,
|
| Poor 3rd year engineering grad student here. My C++ knowledge is
| effectively limited to inheritance and its not enough to meet the task
| at hand. Would love to hire one of you to do this job; but no cash!
|
| My C++ problem: Too much data, the need to collect various statistics,
| the need to be very flexible, and code that needs to be easily
| maintained and reused.
|
| My current approach: Create a database for each object type along the
| following lines: Items of "Type" go into "Types" which is basically a
| vector of "Type's". Database Types class functions exist for I/O and
| statistics gathering the objects of "Type". I continue this for classes
| Y and Z. Classes Type, Y, and Z all derive from the same base class
| "Datum".
|
| My apparent problem: The "Database" code for Type, Y, and Z are all
| essentially the same, but I need to rewrite the database code for each
| and every user defined object. The database code sounds like a case for
| templates, but there seems to be some rule agains user defined objects
| accessing their functions from within a template. If I want to sort
| "Type" by "name" how can I if I can't access "name" within the
| database? My attempt to derive the Databse for Type (Types) from "Data"
| also doesn't work because I need to declare the vector<Type*> within
| "Data" - virtually the same problem I had with templates.
|
| (1) Templates: Can't use class member functions within a template
| (2) Inheritance: Can't declare a different type of vector in the base
| class
|
| Solutions: I am open to anything. Is there a better design philosophy
| to which I may adhere? I have about 10 user defined classes which all
| have at least some degree of interrelationship which I would like to
| capture.

[snip]

To provide you with assistance, you first need to assist us.

Your description is very obscure - Discussing 'Type', 'Types',
'Y' and 'Z' don't really help too much.

Can you provide in code (Just a skeleton hierarchy, with better
chosen names, and only one data member and one member function
in each class, defined in-line (in the class)), to illustrate
the problem ?

It's not that hard do present it in such a way, is it ?

Once we can properly establish your needs, we can move forward
from there, but you can't expect us to wade through something
that is so obscurely described to begin with, and come up with
reasonable advice - Well, at least I cant :-)

Cheers.
Chris Val



Relevant Pages

  • Re: MailMerge hangs and crashes with Access on Server
    ... I have mapped out the path to the final query that is used to get to the ... the database is locked and Word will not open the data source. ... have kept the Word templates and the Access frontend locally on my machine, ... and moved the backend to the server. ...
    (microsoft.public.word.mailmerge.fields)
  • Re: MailMerge hangs and crashes with Access on Server
    ... have kept the Word templates and the Access frontend locally on my machine, ... and moved the backend to the server. ... letters/catalogs, and populates the templates nicely, when the database is ...
    (microsoft.public.word.mailmerge.fields)
  • Re: MailMerge hangs and crashes with Access on Server
    ... There are no dialog boxes, and actually, I have now split the database, and have kept the Word templates and the Access frontend locally on my machine, and moved the backend to the server. ... Dim objWord As Word.Document ...
    (microsoft.public.word.mailmerge.fields)
  • Re: Is ASP.NET really as good as they claim? (No, this isnt a troll, please read)
    ... >> data from your database. ... The object-oriented nature of the .Net platform ... By making good use of inheritance, ... The key is good architecture and design. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Design query - inherited data structures
    ... Can I implement any form of inheritance with typed DataSets in a similar manner to classes, or do I have to implement a completely separate DataSet for each document type, although much of the code would be identical? ... Would I possibly be better off using the aforementioned class hierarchy, loading the data from the database into instances of these classes and then binding interface components to these objects or is this needlessly complex? ... I'm a bit confused as to when to use business objects for interface binding rather than DataSets but that's almost another question. ...
    (microsoft.public.dotnet.framework.adonet)