C++ problem

This is my deposit implementation code:
-----------------------------------------------------------------------------
#include"deposit.h"
#include<iostream>

double Deposit::depositFunds(){
do {

std::cout << "Deposit options:" << std:: endl;
std::cout << "1 - Enter Any Number to deposit" << std::endl;
std::cout << "2- cancel transaction" << std::endl;
std::cout << "choose a deposit option (1-2)" << std::endl;

std::cin >> selectedOption;
switch (selectedOption) {
case 1:
std::cout << "Please the Number you want to deposit" << std::endl;
std::cin >> ValueToDeposit;
return balance = balance + ValueToDeposit;
isNotFinished = false;
break;
case 2:
isNotFinished = false;
break;
default:
std::cout << "Invalid option! Try again." << std::endl;
break;
}
} while (isNotFinished);

}
-----------------------------------------------------------------------------

This is the header code of deposit
-----------------------------------------------------------------------------
#ifndef deposit_H
#define deposit_H
#include<iostream>
class Deposit {
public:
int selectedOption = -1;
bool isNotFinished = true;
double balance;
double ValueToDeposit;

double depositFunds();
};

#endif // !deposit_H
_________________________________________________________________________

This is the main
-----------------------------------------------------------------------------
#include <iostream>
#include <string>
#include"deposit.h"
using namespace std;

double balance = 0.0;
double interest = 0.01;
double valueToWithdraw;
double ValueToDeposit;
double finalbalance =0.0;

bool login() {
string account = "professor";
int pin = 12345;
int givenPin = -1;
bool isAccountInvalid = true;
bool isPinInvalid = true;

cout << "Welcome!" << endl;

while (isAccountInvalid) {

cout << "Please enter your user name: ";
cin >> account;

if (account == "professor") {
isAccountInvalid = false;
}
else {
cout << "Invalid username! Try again." << endl;
}
}

while (isPinInvalid) {

cout << "Please enter your password: ";
cin >> givenPin;

if (givenPin == pin) {
isPinInvalid = false;
}
else {
cout << "Invalid password! Try again." << endl;
}

}

return true;
}

int getUserOption() {

int selectedOption = -1;

cout << "*****************************************" << endl;
cout << "Main menu:" << endl;
cout << " 1 - Balance" << endl;
cout << " 2 - Withdraw cash" << endl;
cout << " 3 - Deposit funds" << endl;
cout << " 4 - Interest Accrued" << endl;
cout << " 5 - Exit" << endl;
cout << "*****************************************" << endl;
cout << "Enter a choice: " << endl;

cin >> selectedOption;

return selectedOption;

}

void viewbalance() {
cout << "Your current balance is" << endl;
cout << "$" << balance << endl;
}





int main() {
Withdraw w;
Deposit d;
Interest i;
if (login()) {

int isNotFinished = true;

do {

switch (getUserOption()) {
case 1:
viewbalance();
break;
case 2:
w.withdrawCash();
break;
case 3:
d.depositFunds();
break;
case 4:
i.currentinterest();
break;
case 5:
isNotFinished = false;
break;
default:
cout << "Invalid option! Try again." << endl;
break;
}

} while (isNotFinished);

}



cout << "\n\t\t*****************************************" << endl;
cout << "\t\tAmount Withdrawn :\t\t" << valueToWithdraw << endl;
cout << "\t\tAmount Deposit :\t\t" << ValueToDeposit << endl;
cout << "\t\tFinal Balance :\t\t\t" << finalbalance << endl;
cout << "\n\t\t*****************************************" << endl;

return 0;

}
-----------------------------------------------------------------------------
My question is I can not return the deposit, which I input into the deposit.cpp file, to the int main, please help....
I can not return the deposit, which I input into the deposit.cpp file, to the int main
Well, ok... But it seems there’re other issues, doesn’t it?
Since your code is still short, let’s temporary unify it in one file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include <iostream>
#include <string>

class Deposit {
public:
    int selectedOption = -1;
    bool isNotFinished = true;
    double balance;
    double ValueToDeposit;

    double depositFunds();
};

double Deposit::depositFunds()
{
    do {
        std::cout << "Deposit options:"
                     "\n1 - Enter Any Number to deposit"
                     "\n2- cancel transaction"
                     "\nchoose a deposit option (1-2): ";
        std::cin >> selectedOption;
        switch (selectedOption) {
        case 1:
            std::cout << "Please enter the Number you want to deposit: ";
            std::cin >> ValueToDeposit;
            return balance += ValueToDeposit;
            isNotFinished = false;
            break;
        case 2:
            isNotFinished = false;
            break;
        default:
            std::cout << "Invalid option! Try again.\n";
            break;
        }
    } while (isNotFinished);
}


double balance = 0.0;
double interest = 0.01;
double valueToWithdraw;
double ValueToDeposit;
double finalbalance =0.0;

bool login();
int getUserOption();
void viewbalance();

int main()
{
    Withdraw w;
    Deposit d;
    Interest i;
    if (login()) {
        int isNotFinished = true;

        do {
            switch (getUserOption()) {
            case 1: viewbalance();              break;
            case 2: w.withdrawCash();           break;
            case 3: d.depositFunds();           break;
            case 4: i.currentinterest();        break;
            case 5: isNotFinished = false;      break;
            default: std::cout << "Invalid option! Try again.\n"; break;
            }
        } while (isNotFinished);
    }
    std::cout << "\n\t\t*****************************************\n"
                 "\n\t\tAmount Withdrawn :\t\t" << valueToWithdraw
                 "\n\t\tAmount Deposit :\t\t" << ValueToDeposit
                 "\n\t\tFinal Balance :\t\t\t" << finalbalance
                 "\n\t\t*****************************************\n";
    return 0;
}

bool login()
{
    std::string account = "professor";
    int pin = 12345;
    int givenPin = -1;
    bool isAccountInvalid = true;
    bool isPinInvalid = true;

    std::cout << "Welcome!\n";

    while (isAccountInvalid) {
        std::cout << "Please enter your user name: ";
        std::cin >> account;
        if (account == "professor") { isAccountInvalid = false; }
        else { std::cout << "Invalid username! Try again.\n"; }
    }

    while (isPinInvalid) {
        std::cout << "Please enter your password: ";
        std::cin >> givenPin;
        if (givenPin == pin) { isPinInvalid = false; }
        else { std::cout << "Invalid password! Try again.\n"; }
    }

    return true;
}

int getUserOption()
{
    int selectedOption = -1;
    std::cout << "*****************************************\n"
                 "Main menu:\n"
                 " 1 - Balance\n"
                 " 2 - Withdraw cash\n"
                 " 3 - Deposit funds\n"
                 " 4 - Interest Accrued\n"
                 " 5 - Exit\n"
                 "*****************************************\n"
                 "Enter a choice: ";
    std::cin >> selectedOption;

    return selectedOption;

}

void viewbalance() { std::cout << "Your current balance is\n$" << balance << '\n'; }


If you try to compile the above code, it shows a long list of errors and the procedure stops.
Not all of them are connected with your class Deposit; on the contrary, it seems you need at least other two classes, Interest and Withdraw.
Actually, if we can’t even compile your code, it will be hard to find errors in it.
If you made it at least nearly compilable, I'm pretty sure you'd get more answers on this forum.
Topic archived. No new replies allowed.