[英]Function does not take 3 arguments C++ error? [on hold]
I have a bank account system where I am trying to make an account.我有一个银行账户系统,我正在尝试创建一个账户。 I have tried changing the variables in the header file.我尝试更改 header 文件中的变量。 But I keep getting the error when I am calling the method set Account:但是当我调用方法集帐户时,我不断收到错误消息:
1>C:\Users\hamza\source\repos\Account\Account\Accountexample.cpp(9,38): error C2660: 'Account::setAccount': function does not take 3 arguments
1>Generating Code...
1>C:\Users\hamza\source\repos\Account\Account\Account.h(11,7): message : see declaration of 'Account::setAccount'
1>Done building project "Account.vcxproj" -- FAILED.
My Account Class:我的帐户 Class:
#include "pch.h"
#include "Account.h"
using namespace std;
Account::Account()
{
id = "";
name = "";
balance = 0;
}
Account::~Account()
{
}
void Account::credit(double amount) {
balance += amount;
}
void Account::setAccount(string id, string name, double balance) {
id = "insert id";
name = "insert name";
balance = 0;
}
void Account::printAccount() {
cout << "\naccount id is " << id << "account name is" << name << "account balance is " << balance;
}
Class where I am printing from(Accountexample): Class 我从中打印(帐户示例):
#include "pch.h"
#include "Account.h"
using namespace std;
int main()
{
Account t;
t.setAccount("2321", "32312", 213.50);
return 0;
}
Here is the header file(Account.h):这是 header 文件(Account.h):
#pragma once
class Account
{
public:
Account();
~Account();
void credit(double);
void debit(double);
void getbalance();
void printAccount();
void setAccount(string id, string name, double balance);
private:
string id; //0-23
string name; //0-59
double balance; //0-59
};
I have managed to get the answer.我设法得到了答案。 It is to add using namesapce std to the header file:就是将 using namesapce std 添加到 header 文件中:
#pragma once
using namespace std;
class Account1
{
public:
Account1();
~Account1();
void setAccount(string id, string name, double balance);
void credit(double);
void debit(double);
void getbalance();
void printAccount();
private:
string id; //0-23
string name ; //0-59
double balance; //0-59
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.