Click here to Skip to main content
15,920,031 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: MFC - Changing text color Pin
Alessandra777-Feb-07 13:39
Alessandra777-Feb-07 13:39 
QuestionHelp with simple Visual C++ HTTP Client Pin
drows7-Feb-07 11:42
drows7-Feb-07 11:42 
AnswerRe: Help with simple Visual C++ HTTP Client Pin
Ravi Bhavnani7-Feb-07 14:11
professionalRavi Bhavnani7-Feb-07 14:11 
AnswerRe: Help with simple Visual C++ HTTP Client Pin
ThatsAlok7-Feb-07 20:05
ThatsAlok7-Feb-07 20:05 
QuestionPython to C++ Pin
kerthy_297-Feb-07 9:59
kerthy_297-Feb-07 9:59 
QuestionRe: Python to C++ Pin
David Crow7-Feb-07 10:24
David Crow7-Feb-07 10:24 
AnswerRe: Python to C++ Pin
kerthy_297-Feb-07 12:07
kerthy_297-Feb-07 12:07 
GeneralRe: Python to C++ Pin
Jörgen Sigvardsson7-Feb-07 12:44
Jörgen Sigvardsson7-Feb-07 12:44 
Account seems about right. It's a noun, so a class is appropriate. However, Deposit and Withdraw are verbs. This indicates that they should be operations rather than classes.

What do you think about this design: (I will let you fill in the code.. it's your assignment! Poke tongue | ;-P )
class Account {
   int balance;
public:
   void Deposit(int amount) 
   {
       // code goes here...
   }
 
   void Withdraw(int amount) 
   {
       // code goes here...
   }
 
   void SetBalance(int balance)
   {
       // code goes here...
   }
  
   int CurrentBalance() 
   {
       // code goes here...
   }
};
I made the operations part of the Account class. In an enterprise class design, this should be designed a bit differently. But let's not shoot over the target - the aim is to learn the C++ language, right? I also added SetBalance and CurrentBalance so that client code (fancy name for code which uses objects of a class), can initialize the object and inspect the object.

I would like to know how you reasoned when you made your design. Don't see this is as criticism. If there's one thing I've learned during the years, is that if you try to explain your own design in human language, the design mistakes will be very easy (or at least easier) to spot. The golden rule is that if it doesn't make sense in a human language, it won't make sense in a programming language.

--
Verletzen zerfetzen zersetzen zerstören
Doch es darf nicht mir gehören
Ich muss zerstören

GeneralRe: Python to C++ Pin
kerthy_297-Feb-07 12:53
kerthy_297-Feb-07 12:53 
GeneralRe: Python to C++ Pin
Jörgen Sigvardsson7-Feb-07 13:04
Jörgen Sigvardsson7-Feb-07 13:04 
GeneralRe: Python to C++ Pin
Garth J Lancaster7-Feb-07 14:24
professionalGarth J Lancaster7-Feb-07 14:24 
QuestionDLL renaming Pin
act_x7-Feb-07 9:37
act_x7-Feb-07 9:37 
AnswerRe: DLL renaming Pin
Hamid_RT7-Feb-07 18:29
Hamid_RT7-Feb-07 18:29 
AnswerRe: DLL renaming Pin
prasad_som7-Feb-07 18:39
prasad_som7-Feb-07 18:39 
QuestionMFC or VB.net Pin
Member 38045467-Feb-07 7:51
Member 38045467-Feb-07 7:51 
AnswerRe: MFC or VB.net Pin
Hamid_RT7-Feb-07 8:18
Hamid_RT7-Feb-07 8:18 
GeneralRe: MFC or VB.net Pin
Mark Salsbery7-Feb-07 8:30
Mark Salsbery7-Feb-07 8:30 
AnswerRe: MFC or VB.net Pin
James R. Twine7-Feb-07 8:36
James R. Twine7-Feb-07 8:36 
AnswerRe: MFC or VB.net Pin
led mike7-Feb-07 9:42
led mike7-Feb-07 9:42 
GeneralRe: MFC or VB.net Pin
Mark Salsbery7-Feb-07 9:52
Mark Salsbery7-Feb-07 9:52 
GeneralRe: MFC or VB.net Pin
led mike8-Feb-07 11:26
led mike8-Feb-07 11:26 
GeneralRe: MFC or VB.net Pin
Mark Salsbery8-Feb-07 11:30
Mark Salsbery8-Feb-07 11:30 
QuestionFinding the VirtualStore location in Vista Pin
Will Singer7-Feb-07 7:47
Will Singer7-Feb-07 7:47 
AnswerRe: Finding the VirtualStore location in Vista Pin
Michael Dunn7-Feb-07 8:49
sitebuilderMichael Dunn7-Feb-07 8:49 
GeneralRe: Finding the VirtualStore location in Vista Pin
David Crow7-Feb-07 10:27
David Crow7-Feb-07 10:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.