🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.lang.learn.c-c++
Article #56

Re: class help

#56
From: R. Scott Mellow
Date: Tue, 01 May 2001 18:56
60 lines
3748 bytes
"Antony Carr" <antony.carr@btinternet.com> wrote in message
news:9cms6r$emm$1@neptunium.btinternet.com...
: Right heres a question for you all, i am a little stuck and hope
someone can
: help me...
: The best way of describing my problem is by showing you an example of
what i
: am trying to do, so here it is...
: I have a two files, a .cpp file containing the main() etc, and a
header file
: (bank.hpp).
: inside the header file there are two classes BankAccount and BankDB.
: BankAccount contains the account name, & balance. BankDB amongst other
: things creats for each instance of BankAccount the name in which the
account
: is held. Now heres the problem, i can for a single instance of
BankAccount
: set the name & Balance indervidually , however how would you go about
: calling from the class of BankDB an instance of BankAccount ???
Whenever i
: try i get error messagess generated. I have attatched to this message
the
: two files concerned. If any one could help i would be eternally
greatfull
: :-)
:
: Antony Carr
: antony.carr@btinternet.com

[snip] and a half

I cannot help you with your specific problem because I am unable to
compile (let alone read) your code. From what I can discern, I have the
following advice:

Rethink your design. For starters, you need more than 2 classes because
you have more than 2 distinct concepts. Also, the inheritance between
BankDB and BankAccount does not make sense. Generally, an inheritance
would imply an is_a relationship. i.e., if class C inherits from class B
then C is a B.

One thing you might want to do as an exercise is to come up with a
BankAccount class that has only what it needs... nothing else. Do the
same for the other 'objects' in your program. When you have each
object's interface written down, then work on how they interact with
each other. What I often do is create the class with only data and
constructors. Once all my classes are written this way, I start trying
to use them in a program. The interface (public methods) almost writes
itself.

When you are to the point of implementing your new design, ask here
about any specific problems you have with the code. You should read the
faq
     http://snurse-l.org/acllc-c++/faq

before you do because that can also give you ideas on how to solve your
problems.

hth
R.
Technical Details
Message-ID: <oFDH6.1175$Gf1.266397@paloalto-snr1.gtei.net>
Path: arc1-ca.pugleaf.net!newsfeed.google.com!newsfeed.stanford.edu!paloalto-snf1.gtei.net!paloalto-snh1.gtei.net!news.gtei.net!paloalto-snr1.gtei.net.POSTED!not-for-mail
References: <9cms6r$emm$1@neptunium.btinternet.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 114592,bcfa6c5c8a6717c0
X-Google-Attributes: gid114592,public
X-Google-Thread: 10d4ba,bcfa6c5c8a6717c0
X-Google-Attributes: gid10d4ba,public
X-Google-Thread: 109fba,bcfa6c5c8a6717c0
X-Google-Attributes: gid109fba,public
X-Google-ArrivalTime: 2001-05-01 11:56:37 PST
Path: arc1-ca.pugleaf.net!newsfeed.google.com!newsfeed.stanford.edu!paloalto-snf1.gtei.net!paloalto-snh1.gtei.net!news.gtei.net!paloalto-snr1.gtei.net.POSTED!not-for-mail
From: "R. Scott Mellow" <RSMellow@dmd.to>
Newsgroups: alt.comp.lang.learn.c-c++,att.lang.c++,comp.lang.c++
References: <9cms6r$emm$1@neptunium.btinternet.com>
Subject: Re: class help
Lines: 64
Organization: Destiny Mold Design
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-Mimeole: Produced By Microsoft MimeOLE V5.50.4133.2400
Message-ID: <oFDH6.1175$Gf1.266397@paloalto-snr1.gtei.net>
X-Trace: +L6QmwxnsyHOuvWofkNK+HSaje1lNAtdfbJGRrH5VbpCs71gj9ShGvKY5GmTxcBF5CFC4spj3DUx!o77W+et9gXNIzCS7WCaJHBDt0hVFG1c7j/ZMssnHByOYH5sE0FC9J/vkFHl6KtEl5RkVGXx+mJLr!dUQuVaU=
X-Complaints-To: abuse@gte.net
X-Abuse-Info: Please be sure to forward a copy of ALL headers
X-Abuse-Info: Otherwise we will be unable to process your complaint properly
NNTP-Posting-Date: Tue, 01 May 2001 18:56:20 GMT
Distribution: world
Date: Tue, 01 May 2001 18:56:20 GMT