简体   繁体   English

Function不走3 arguments C++错误? [等候接听]

[英]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.

相关问题 C ++错误C2660:函数没有3个参数 - C++ Error C2660: Function does not take 3 arguments 错误C2660:函数没有2个参数C ++ - Error C2660: function does not take 2 arguments C++ 函数不接受1个参数C ++ - function does not take 1 arguments c++ C ++函数不接受0个参数 - c++ function does not take 0 arguments c++ 的 matplotlib 给出此错误:'PyObject_CallObject': function 不占用 3 ZDBC16FB4CAA5BDA882EBD77 - matplotlib for c++ gives this error: 'PyObject_CallObject': function does not take 3 arguments Visual C ++ ::&#39;malloc&#39;中的奇怪错误:函数没有1个参数 - Strange errors in Visual C++ :: 'malloc' : function does not take 1 arguments 错误C2660:&#39;Aba :: f&#39;:函数未使用0个参数 - error C2660: 'Aba::f' : function does not take 0 arguments 奇怪的错误c2660“函数不带1个参数” - Strange error c2660 “function does not take 1 arguments” 错误C2660:&#39;MouseListener :: MousePressed&#39;:函数未采用4个参数 - error C2660: 'MouseListener::MousePressed' : function does not take 4 arguments C ++中的特征库给出错误C2660:&#39;Eigen :: MatrixBase <Derived> :: eigenvalues&#39;:函数不带2个参数 - eigen library in C++ gives error C2660: 'Eigen::MatrixBase<Derived>::eigenvalues' : function does not take 2 arguments
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM