C++;使用类的小型银行程序 我想在C++中创建一个银行程序,它将存储客户信息(可能在文本文件或某种类型)中,例如:

C++;使用类的小型银行程序 我想在C++中创建一个银行程序,它将存储客户信息(可能在文本文件或某种类型)中,例如:,c++,C++,如何使用构造函数?可能需要将余额和accountnum设置为0。我如何才能做到这一点,以及如何实现其他功能?以下是如何实现的。创建并传递要作为参数分配给对象的值 #include <iostream> #include <string> class bankAccounts { private: std::string customerName; char accType; int accountNo; double accBalance

如何使用构造函数?可能需要将余额和accountnum设置为0。我如何才能做到这一点,以及如何实现其他功能?

以下是如何实现的。创建并传递要作为参数分配给对象的值

#include <iostream>
#include <string>

class bankAccounts
{
private:
    std::string customerName;
    char accType;
    int accountNo;
    double accBalance;

public:
    bankAccounts();

    bankAccounts(std::string cn ,char act, int acno, double accB) //Parameterized constructor
    {
        customerName =cn;
        accType=act;
        accountNo=acno;
        accBalance=accB;
    }

    //Implement your functions inside/ outside the class

    // displayAccount();
    // depositAccount();
    // withdrawAccount();
    // deleteAccount();
    // showAccounts();

};


int main()
{
    std::string customerName;
    char accType;
    int accountNo;
    double accBalance;
    std::cin>>customerName>>accType>>accountNo>>accBalance;//get your data
    bankAccounts B(customerName, accType, accountNo, accBalance);
    //object B has all attributes you wanted

    //Enjoy :)

    return 0;
} 
#包括
#包括
类别银行账户
{
私人:
std::字符串客户名称;
字符类型;
国际会计编号;
双平衡;
公众:
银行账户();
bankAccounts(std::string cn,char act,int acno,double accB)//参数化构造函数
{
客户名称=cn;
accType=act;
accountNo=acno;
accBalance=accB;
}
//在类内/类外实现您的函数
//displayAccount();
//存款账户();
//提款账户();
//deleteCount();
//showcounts();
};
int main()
{
std::字符串客户名称;
字符类型;
国际会计编号;
双平衡;
std::cin>>客户名称>>账户类型>>账户号>>账户余额;//获取数据
银行账户B(客户名称、账户类型、账户号、账户余额);
//对象B具有您想要的所有属性
//享受:)
返回0;
} 

成功步骤:1。A.2.了解C++中的类如何工作,包括构造函数/析构函数、继承、多态性以及所有相关的东西。3.想想看。编写代码。如果不起作用,请重写或在这里询问有关堆栈溢出的特定问题。请注意,我在这里不是在挖苦人,而是确实很有帮助。抱歉,我不会编译。我不是故意的。我只是概述一下。等等,我会的,但只有在你的程序编译的情况下。就目前情况而言,情况并非如此。不返回类型的函数声明只允许在<99中,而C++中不允许。为什么要使用
string
而不是
std::cin
?名称空间说明符让我很恼火。是的,完成了。很抱歉,我目前不与我的编辑器:现在的PLOOKS好,但使用一个初始化列表作为普通的C++。
Class bankAccounts
{
   private:
string customerName
char accType
int accountNo
double accBalance
   public:
bankAccounts()
~bankAccounts()
displayAccount()
depositAccount()
withdrawAccount()
deleteAccount()
showAccounts()
#include <iostream>
#include <string>

class bankAccounts
{
private:
    std::string customerName;
    char accType;
    int accountNo;
    double accBalance;

public:
    bankAccounts();

    bankAccounts(std::string cn ,char act, int acno, double accB) //Parameterized constructor
    {
        customerName =cn;
        accType=act;
        accountNo=acno;
        accBalance=accB;
    }

    //Implement your functions inside/ outside the class

    // displayAccount();
    // depositAccount();
    // withdrawAccount();
    // deleteAccount();
    // showAccounts();

};


int main()
{
    std::string customerName;
    char accType;
    int accountNo;
    double accBalance;
    std::cin>>customerName>>accType>>accountNo>>accBalance;//get your data
    bankAccounts B(customerName, accType, accountNo, accBalance);
    //object B has all attributes you wanted

    //Enjoy :)

    return 0;
}