Thread: class

  1. #1

    Wink class

    If someone has the time can you look at this and let me know what I am missing...I am not sure if my inspector functions are ok and what about the private area???? should there be functions down there also...HELP =)

    #include <iostream>
    #include <string>
    using namespace std;

    class StudentAccount
    // constructor that initializes the data members

    StudentAccount(string ID, string name, double init);

    // Mutator functions
    void setStudentID(string ID);
    void setStudentName(string name);
    void setBalance(double init);

    // Inspector functions
    string getStudentID()
    return studentID;
    string getStudentName()
    return studentNAME;
    double getBalance()
    return balance;
    // Facilitator functions
    // Add amount to balance
    void CreditAccount(double amount);

    { cout<< "Enter the amount to be added;"<< endl;
    int amount=0;
    float totalbalance=0;
    cin>> amount;
    amount + balance = totalbalance
    // Subtract amount from balance. If there is not enough
    // money in the account, display an error message and do not
    // modify the balance.
    void DebitAccount(double amount);
    { balance - amount = balance
    if(balance > totalbalance)
    { cout << "There is not enough money in your account to debit that amount"<<endl;

    // Display all values
    void PrintAccount();

    string StudentID; // it in the form ###-##-####
    string StudentName; // Student's first and last name
    double balance; // account balance

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    If you bothered to compile it instead of running to us to tell you if you did okay, you'd realize that it still needs work and why.

    My best code is written with the delete key.

  3. #3
    First of all if you noticed there is no main, I am not supposed to compile it. I'm questioning on how to do something...this message board is to get help am I correct or are you all here to bash anyone that has a queston b/c the haven't programmed since they came out of the womb.....Not all of us are experts ya know..There is no need to be so mean=)

  4. #4
    Registered User
    Join Date
    Feb 2002
    -The debit account function misses a }
    -The inspector functions could (should?) be made inline. The compiler might do this for you, but you can newer be to sure. (If you put the definition of the function outside the class it will not be inlined by the compiler... In most cases)
    -You should have a virtual destructor. This is for inheritance reasons.
    -Missing default constructor. This is not neaded, but something I usually have anyway. The compiler migth create this for you, but then again: don't be to sure about it. You could do like this also, to have an default constructor, kind of thing:
    StudentAccount(string ID = "default", string name = "default", double init = 0.0);
    -Since I think the mutator functions doesn't do more than just setting the value, these should be inlined to.
    -I would go for more OOP when I'm at it. Create a baseAccount class. Let Student account inherit from baseAccount. Then you could make an TeacherAccount the same way. without any extra work.

    class BaseAccount
    class StudentAccount: public BaseAccount
    class TeacherAccount: public BaseAccount

  5. #5
    thanks ninebit that helps a lot=)
    I appreciate your assistance=)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Class design problem
    By h3ro in forum C++ Programming
    Replies: 10
    Last Post: 12-19-2008, 09:10 AM
  2. Two conceptual questions
    By AntiScience in forum C++ Programming
    Replies: 3
    Last Post: 11-01-2007, 11:36 AM
  3. Defining derivated class problem
    By mikahell in forum C++ Programming
    Replies: 9
    Last Post: 08-22-2007, 02:46 PM
  4. matrix class
    By shuo in forum C++ Programming
    Replies: 2
    Last Post: 07-13-2007, 01:03 AM
  5. Abstract class problem
    By VanJay011379 in forum C++ Programming
    Replies: 9
    Last Post: 07-31-2002, 01:30 PM