Thread: This is my Homework

  1. #16
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    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
    Location
    Inside my computer
    Posts
    24,654
    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
    Chappell Hill, Texas
    Posts
    2,332
    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
    Mainframe assembler programmer by trade. C coder when I can.

  6. #21
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    >> 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.

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, 03:16 PM
  3. Homework
    By kermi3 in forum Windows Programming
    Replies: 5
    Last Post: 09-15-2001, 11:48 AM
  4. Homework
    By kermi3 in forum C Programming
    Replies: 0
    Last Post: 09-10-2001, 01:26 PM