屏幕变黑,当我输入某些内容时,它又返回到C ++中的编码窗口

问题描述 投票:-2回答:1

我是一个初学者,我使用构造函数的概念来编写类似于银行软件的代码,当我执行代码时,它将进入输出屏幕,而当我输入某些内容时,它将返回输入屏幕。我前一段时间已经遇到了这个问题,并且在尝试使用构造函数时,已经在不同的程序中遇到了。感谢您的帮助。

#include<iostream.h>
#include<conio.h>
class account
{
public:
    int i, j, count, d, sum;
    struct bank
    {
        int deb[5];
        int cre[5];
    };
    bank b;
    account()
    {
        int deposit();
        int credit();
        int balance();
    }
    int deposit()
    {
        cout << "Enter the amount you want to deposit: ";
        i = 0, count;
        cin >> b.cre[i];
        i++;
        d = totaldep();
        cout << "Total deposit is: " << d;
        return 0;
    }
    int credit()
    {
        cout << "Enter the amout you want to take: ";
        j = 0;
        cin >> b.deb[j];
        j++;
        balance();
        return 0;
    }
    int balance()
    {
        cout << "The balance is " << d - b.deb[j];
        return 0;
    }
    int totaldep()
    {
        for (count = 0; count <= i; count++)
        {
            sum = sum + b.cre[count];
        }
        return sum;
    }
};
void main()
{
    account a;
    clrscr();
    getch();
}
c++ turbo-c++
1个回答
0
投票

因此,正如我所看到的,您正在编写函数声明,但是实际上您需要调用它们。只是不要在函数调用之前编写返回类型。

© www.soinside.com 2019 - 2024. All rights reserved.