任何人都可以帮我解决这个问题 [英] Can anybody help me with this problem

查看:75
本文介绍了任何人都可以帮我解决这个问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道利率是什么问题?当我运行程序时,它给了我

Anybody knows what's the problem is it the interest rate? When i run the program it gives me

ld.exe||cannot open output file bin\Debug\Assignemts.exe Permission denied|
||=== Build finished: 1 errors, 0 warnings (0 minutes, 5 seconds) ===|





我尝试过:





What I have tried:

#include <iostream>
#include <iomanip>
#include <stdlib.h>

using namespace std;
class bank_account
{
public:
    bank_account();
    bank_account(int account_no, float opening_balance);
    void get_interest(float interest_rate);
    void balance(float amount);
    void deposit(float amount);
    void withdrawal(float amount);
    void display_bank_report();
    void display_headings();
private:
    int dm_account_no;
    float dm_balance;
    float dm_interest_rate;
    float dm_interest_earned;
    float dm_total_balance;
    float dm_total_interest;
};
bank_account::bank_account()
{
dm_account_no=0;
dm_balance = 0;
}
bank_account::bank_account(int account_no, float opening_balance)
{
    dm_account_no = account_no;
    ///Must Add 10% To Opening balance
    dm_balance = opening_balance *1.1;
}

void bank_account::deposit(float amount)
{
    dm_balance = dm_balance + amount;
}
void bank_account::withdrawal(float amount)
{
    dm_balance = dm_balance - amount;
}
void bank_account::get_interest(float interest_rate)
{
    dm_interest_rate= interest_rate;
    dm_interest_earned = dm_interest_rate * dm_balance;

}
void bank_account::display_bank_report()
{
cout<<left<<setw(15)<<dm_account_no <<setw(15)<< dm_balance << setw(15) << dm_interest_rate<< endl;
}
void bank_account::display_headings()
{
cout<<left<<setw(15)<<"Account" <<setw(15)<< "Closing" << setw(15) << "Interest"<< endl;
cout<<left<<setw(15)<<"Number" <<setw(15)<< "Balance" << setw(15) << "Earned"<< endl;

}

int reply;
int account_no [4] = {80045001, 80045002, 80045003, 80045004};
float opening_balance [4] = {100, 200, 300, 400};
float deposit1 [4] = {100, 200, 300, 400};
float deposit2 [4] = {10, 200, 300, 400};
float withdrawal1 [4] = {50, 50, 50, 50};
float withdrawal2 [4] ={155, 50, 50, 50};
float get_interest [4] = {.01, .02, .03, .04};

int main()
{
    system ("COLOR A4");

    bank_account account1(account_no[0], opening_balance[0]);
    bank_account account2(account_no[1], opening_balance[1]);
    bank_account account3(account_no[2], opening_balance[2]);
    bank_account account4(account_no[3], opening_balance[3]);
    bank_account account5;

    account1.deposit(deposit1[0]);
    account2.deposit(deposit1[1]);
    account3.deposit(deposit1[2]);
    account4.deposit(deposit1[3]);

    account1.withdrawal(withdrawal1[0]);
    account2.withdrawal(withdrawal1[1]);
    account3.withdrawal(withdrawal1[2]);
    account4.withdrawal(withdrawal1[3]);

    cout<< "Do you want to continue Yes or not"<<endl;
    cout<< "Enter Y to continue or N to exit"<<endl;
    cin>>reply;

    if (reply == 'N'){
        cout<<"Goodbye!"<<endl;
        exit(EXIT_FAILURE);}
    cout<<"Continue processing"<<endl;

    account1.deposit(deposit2[0]);
    account2.deposit(deposit2[1]);
    account3.deposit(deposit2[2]);
    account4.deposit(deposit2[3]);

    account1.withdrawal(withdrawal2[0]);
    account2.withdrawal(withdrawal2[1]);
    account3.withdrawal(withdrawal2[2]);
    account4.withdrawal(withdrawal2[3]);

    cout<< "Bank Account System"<< endl;
    account1.display_headings();
    account1.display_bank_report();
    account2.display_bank_report();
    account3.display_bank_report();
    account4.display_bank_report();
    account5.display_bank_report();
    return 0;
}

推荐答案

您的问题不是代码,而是文件系统上的问题。我最好的猜测是你的IDE没有权利编写ld.exe ld.exe正在运行和/或锁定。



尝试手动删除ld.exe(或taks manager)并重建。否则设置另一个输出目录。



提示:在我的示例代码中使用常量和循环来改善代码



Your problem is not the code, but something on your file system. My best guess is that your IDE hasnt the right to write the ld.exe or the ld.exe is running and or locked.

Try to delete the ld.exe by hand (or taks manager) and rebuild. Else set another output directory.

Tip: use a constant and loops like in my sample code to improve your code

const int COUNT_ACCOUNT = 4;
float deposit1 [COUNT_ACCOUNT] = {100, 200, 300, 400};
// in the functions
for( int i = 0; i < COUNT_ACCOUNT; i++ ) {
  deposit1[i] = 0;
}


错误消息

The error message
ld.exe||cannot open output file bin\Debug\Assignemts.exe Permission denied

非常清楚。



ld.exe 是GCC(Gnu编译器集合)的链接器。链接器将已编译的源文件和库放在一起并创建最终的可执行文件。它通常不是直接调用,而是在使用链接参数执行编译器 gcc (或 g ++ )时。在您的情况下,它没有输出目录 bin \Debug \ 的写权限。路径中的反斜杠表示您正在使用Windows。因此,您必须确保允许执行链接器或编译器的用户帐户(可能是您的用户帐户)写入该目录。



如果您是使用某种IDE(集成开发环境)并使用不同的帐户在IDE中创建或使用您的项目。



作为一种快速解决方案,您可以启动Windows资源管理器和检查该目录的权限(它是一个相对目录,可以在项目目录下找到)。要更改资源管理器中的权限,您必须以拥有该目录的用户或管理员身份启动它。然后选择项目目录并对该目录和所有子目录应用相同的所有权和权限。

is quite clear.

ld.exe is the linker of the GCC (Gnu Compiler Collection). A linker puts the compiled source files and libraries together and creates the final executable. It is usually not called directly but when executing the compiler gcc (or g++ in your case) with linking parameters. In your case, it has no write permission to the output directory bin\Debug\. The back slashes in the path indicate that you are using Windows. So you have to ensure that the user account executing the linker or compiler (probably your user account) is allowed to write to that directory.

Such may happen if you are using some kind of IDE (Integrated Development Environment) and created or used your project within the IDE using different accounts.

As a quick solution you may start the Windows Explorer and check the permissions of that directory (it is a relative directory and can probably be found below the project directory). To change the permission within the Explorer, you have to start it as the user who owns the directory or as administrator. Then select the project directory and apply the same ownership and permissions to that directory and all sub directories.


您是否尝试过谷歌 [ ^ ]?


这篇关于任何人都可以帮我解决这个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆