Aus irgendeinem Grund bekomme ich Fehler C2448 von Microsoft Visual Studios. Ich versuche eine Funktion anzurufen, will aber nicht für mich arbeiten. Sieht jemand was falsch ist? Ich versuche, 3 Funktionen während der while-Anweisung mit einem if innerhalb von es jedoch ich dachte, das war, wie eine Funktion aufrufen, aber es funktioniert nicht für mich. Jede Eingabe wird geschätzt.Problem beim Aufruf einer Funktion C++
#include <string>
#include <iostream>
using namespace std;
//int check (cbal && scharge);
//int deposit (cbal && scharge);
//int endt (cbal && scharge && loopend);
int main()
{
float cbal;
float scharge;
float bal;
char selection;
int loopend;
loopend = 1;
cout << "Transactions will take the form of a letter followed by a dollar amount. " <<
"Valid letters are “C” for a check, “D” for a deposit, and “E” for the ending " <<
"transaction(use zero on this transaction). Press <Enter> after each line of input!" << endl;
cout << "Please enter inital balance: ";
cin >> bal;
bal = cbal;
while(loopend == 1)
{
cout << "Please enter a transaction" << endl;
cin >> selection;
if (selection == 'C' || selection == 'c')
{
int check (float cbal, float scharge);
}
else if (selection == 'D' || selection == 'd')
{
int deposit (float cbal, float scharge);
}
else if (selection == 'E' || selection == 'e')
{
int endt (float cbal,float scharge, int loopend);
}
else
{
cout << "Please enter a valid transaction.";
}
}
return 0;
}
int check (float cbal, float scharge)
{
int transaction;
bool flag;
scharge = scharge + .15;
cout << "What is the check amount?" << endl;
cin >> transaction;
cbal = cbal - transaction;
cout << "Transaction ammount: " << transaction << endl
<< "Current Balance: " << cbal << endl
<< "Service Charge Check: $0.15" << endl;
if (cbal < 500 && flag == false)
{
scharge = scharge + 5;
flag = true;
cout << "Service Charge Below $500: $5.00";
}
cout << "Total Service Charges: " << scharge;
return (cbal);
return (scharge);
}
int deposit(float cbal, float scharge)
{
int transaction;
scharge = scharge + .10;
cout << "What is the deposit amount?" << endl;
cin >> transaction;
cbal = cbal + transaction;
cout << "Deposit amount: " << transaction << endl
<< "Current Balance: " << cbal << endl
<< "Service Charge Deposit: $0.10" << endl
<< "Total Service Charges: " << scharge;
return (cbal);
return (scharge);
}
int endt (float cbal, float scharge, int loopend)
{
int transaction;
cout << "Enter transaction amount: ";
cin >> transaction;
if (transaction == 0)
{
cout << "Transaction: End" << endl
<< "Current Balance: " << cbal << endl
<< "Total Service Charges: " << scharge << endl;
cbal = cbal - scharge;
cout << "Final Balance: " << cbal;
loopend = 2;
}
else
cout << "Error: 0 was not the transaction amount";
return (cbal);
return (scharge);
return (loopend);
}
Was denkst du '&&' tut? Haben Sie [ein gutes C++ Buch] (http://stackoverflow.com/q/388242/253056), auf das Sie sich leicht beziehen können? –
&& ist der logische UND-Operator. Ich bin mir nicht sicher, was Sie tun wollen, aber es gehört sicherlich nicht dorthin, wo Sie es verwenden. – OldProgrammer
Wie andere aufzeigen, macht 'int endt (cbal &&ladung && loopend)' keinen Sinn. Was denkst du, was das bedeutet? –