This is my Homework

This is a discussion on This is my Homework within the C++ Programming forums, part of the General Programming Boards category; Get rid of the "display" member function (a bank account should not display anything on the screen unless for debugging ...

  1. #16
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,915
    Get rid of the "display" member function (a bank account should not display anything on the screen unless for debugging purposes). You can show the contents in main instead.
    Otherwise it's acceptable.
    And... do you want it to be able to create more accounts for more customers? Is this what you want to accomplish?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #17
    Super unModrator
    Join Date
    Dec 2007
    Posts
    321
    Quote Originally Posted by Elysia View Post
    Get rid of the "display" member function (a bank account should not display anything on the screen unless for debugging purposes). You can show the contents in main instead.
    Then how will main() access private data members without a member function?
    And... do you want it to be able to create more accounts for more customers? Is this what you want to accomplish?
    Yes.

  3. #18
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,915
    Quote Originally Posted by abk View Post
    Then how will main() access private data members without a member function?
    You can make new ones to return the data you need. In a safe way.

    Yes.
    Then you simply need an array. Std::vector is perfect for it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #19
    Super unModrator
    Join Date
    Dec 2007
    Posts
    321
    Thanks Elysia and Todd.

  5. #20
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    Another couple tips.

    For balance, a double would be a better choice than an int. If I deposit 50 cents, how would you track that?

    Also, when an account is "opened" (when your constructor is called), it would be a good idea to set an initial balance of zero.

    Finally, class names typically would have a capital first letter, so "Account" vs "account".

    Todd
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  6. #21
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,752
    >> For balance, a double would be a better choice than an int. If I deposit 50 cents, how would you track that?

    double isn't actually how real financial software keeps track of money. It's usually just a big integer that's denominated in cents. Because it's always precise and you don't get some of the issues that you would using a floating-point, like the "hole" towards zero, or rounding errors. But for this assignment, you could go with either representation.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Homework
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 11-03-2001, 04:39 PM
  2. Homework
    By kermi3 in forum C++ Programming
    Replies: 15
    Last Post: 09-26-2001, 04:16 PM
  3. Homework
    By kermi3 in forum Windows Programming
    Replies: 5
    Last Post: 09-15-2001, 12:48 PM
  4. Homework
    By kermi3 in forum C Programming
    Replies: 0
    Last Post: 09-10-2001, 02:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21