#include <iostream>
#include <vector>
using namespace std;
class Bank_Account
{
private:
string Account_Owner_Name;
string Account_Owner_Surname;
float Account_Balance;
float Account_Remaining_Loan;
public:
Bank_Account()
{
}
Bank_Account(string Name, string Surname)
{
Account_Owner_Name=Name;
Account_Owner_Surname=Surname;
Account_Balance=0;
Account_Remaining_Loan=0;
}
void get_Account_Info()
{
cout << Account_Owner_Name << " " << Account_Owner_Surname << ":" << endl;
cout << "Balance: " << Account_Balance << endl;
cout << "Loan: " << Account_Remaining_Loan;
}
};
int main()
{
string Register_Name, Register_Surname;
Bank_Account New_Account;
vector <Bank_Account> Accounts;
cout << "Register new account?" << endl;
cin >> Register_confirmation;
if (Register_confirmation==true)
{
cout << "nName: "<< endl;
cin >> Register_Name;
cout << "nSurname: ";
cin >> Register_Surname;
New_Account(Register_Name, Register_Surname);
New_Account.get_Account_Info();
Accounts.push_back(New_Account);
}
"调用没有适当运算符((的类类型的对象或将函数转换为指向函数类型的指针";是我编译它时遇到的错误。我还处于OOP和类的开始阶段,所以有些东西对我来说是新的。任何更正都是受欢迎的。谢谢
进行
New_Account(Register_Name, Register_Surname);
必须在类Bank_Account
中定义一个接受两个参数的operator()
。
看起来你想做
New_Account = Bank_Account(Register_Name, Register_Surname);