当前位置: 首页>>代码示例>>C++>>正文


C++ BankAccount::setAccountNumber方法代码示例

本文整理汇总了C++中BankAccount::setAccountNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ BankAccount::setAccountNumber方法的具体用法?C++ BankAccount::setAccountNumber怎么用?C++ BankAccount::setAccountNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BankAccount的用法示例。


在下文中一共展示了BankAccount::setAccountNumber方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: newAccount

int newAccount(BankAccount account[], int max_accounts, int num_accts){
    BankAccount * b;
    //make sure there is space left
    if(num_accts+1 <= max_accounts){
        b = &account[num_accts];
        string fname, lname, type;
        int SSN;
        double acctbalance;
        cout << endl << "Please enter first name: ";
        cin >> fname;
        cout << endl << "Please enter last name: ";
        cin >> lname;
        cout << endl << "Please enter SSN (Social Security Number): ";
        cin >> SSN;
        cout << endl << "Please enter Account Type: ";
        cin >> type;
        cout << endl << "Please enter Account starting Balance: ";
        cin >> acctbalance;
        b->setFirstName(fname);
        b->setLastName(lname);
        b->setSSN(SSN);
        //increment the account number
        int greatest = 0;
        BankAccount * g;
        for(int i=0; i < num_accts; i++){
            g = &account[i];
            if(g->getAccountNumber() > greatest){
                greatest = g->getAccountNumber();
            }
        }
        greatest++;
        b->setAccountNumber(greatest);
        b->setAccountType(type);
        b->setAccountBalance(acctbalance);
        num_accts++;
        return num_accts;
    }
开发者ID:stephonlawrence,项目名称:Simple-Console-Bank,代码行数:37,代码来源:main.cpp

示例2: read_accts

//Account Functions --------------------------------------------------------------------------------------------------------
int read_accts(BankAccount account[], int max_accounts){
    //start counter
    int count = 0;
    //temporary variables
    string fname, lname, type;
    int SSN;
    double acctbalance;
    //count how moany entries are in the file.
    while(!File.eof() && count < max_accounts){
        File >> fname >> lname >> SSN >> type >> acctbalance;

        count++;
    }
    //loop back to top of file.
    File.clear();
    File.seekg(0, ios::beg);
    //counter for our current account
    int i = 0;
    //create pointer for changing the values at the direct address in memory
    BankAccount * b;
    //loop trhough file and save and set values
    while(!File.eof() && i < count){
        //set our current account into our pointer variable
        b = &account[i];
        //define our file format
        File >> fname >> lname >> SSN >> type >> acctbalance;
        //set all of our values
        b->setFirstName(fname);
        b->setLastName(lname);
        b->setSSN(SSN);
        b->setAccountNumber(i);
        b->setAccountType(type);
        b->setAccountBalance(acctbalance);
        i++;
    }
    return count;
}
开发者ID:stephonlawrence,项目名称:Simple-Console-Bank,代码行数:38,代码来源:main.cpp


注:本文中的BankAccount::setAccountNumber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。