Thread: instances of class....

  1. #1
    Registered User
    Join Date
    May 2009

    instances of class....

    so this is what im trying to accomplish... when it creates the new account i would like for it to create a new instance name so that the information will be saved for that specific holder... as it is now i know the code will simply just overwrite the data. How do i go about this, and also reccomendations for books to buy to learn c++ I've used this sites tutorials and some videos on youtube thus far but would like to get something that goes more in depth...
    thanks cj

    #include <iostream>
    using namespace std;
    class account{
          int number;//acount number
          string holder;//account holder name
          int balance;//current balance
                    number = 0;
                    balance = 0;
          int create(){
              number++;//makes account number different for new holder
              cout<<"Please enter your name:"<<endl;
              cin>> holder;
    int main(){
    int choice;
        cout<<"1. Create account" <<endl;
        cout<<"2. Check Balance" <<endl;
        cout<<"3. Deposit Money" <<endl;
        cout<<"4. Take out money" <<endl;
        cout<<">> ";
        cin>> choice;
        account go;
        switch (choice){
        case 1:
        case 2:
        case 3:
        case 4: 

  2. #2
    Registered User
    Join Date
    Apr 2006
    As you have it, creating an account would be useless, as you have no way to switch from one account to another.

    As a scalable approach, I recommend designing an around manager, that has methods like create account, switch account, and delete account. This might seem excessive, because of the potentially simple implementation of these methods, but in your case it will orgonise your thoughts, and keep you main function easy to follow.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  3. #3
    Registered User
    Join Date
    Oct 2009
    See what i am getting from your question is that

    whenever you will instantiate a class then there member variables value will differ from object to object if they are not static ok, so you can have any values holder, balance etc

    And for values you can have get set methods for it

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stuck with function
    By scmurphy64 in forum C Programming
    Replies: 9
    Last Post: 11-10-2009, 11:41 AM
  2. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  3. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM
  4. Abstract class problem
    By VanJay011379 in forum C++ Programming
    Replies: 9
    Last Post: 07-31-2002, 01:30 PM
  5. Replies: 4
    Last Post: 09-12-2001, 02:05 PM