Ich bin ziemlich neu in C++ und bin mit Funktionen rum. Ich kann nicht herausfinden, warum der folgende Code nicht funktioniert, jede Hilfe würde sehr geschätzt werden.Was ist los mit meinen Funktionen
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main() {
movieOutput("Hello");
return 0;
}
//This is just for a little extra versatility
int movieOutput(string movieName,int aTix = 0,int cTix = 0,float grPro = 0.0,float nePro = 0.0,float diPro = 0.0){
//I don't understand whether I should declare the arguments inside the
//functions parameters or in the function body below.
/*string movieName;
int aTix = 0, cTix = 0;
float grPro = 0.0, nePro = 0.0, diPro = 0.0;*/
cout << "**********************Ticket Sales********************\n";
cout << "Movie Name: \t\t" << movieName << endl;
cout << "Adult Tickets Sold: \t\t" << aTix << endl;
cout << "Child Tickets Sold: \t\t" << aTix << endl;
cout << "Gross Box Office Profit: \t" << grPro << endl;
cout << "Net Box Office Profit: \t" << nePro << endl;
cout << "Amount Paid to the Distributor: \t" << diPro << endl;
return 0;
}
Die Build-Fehler Ich erhalte
`Build:(compiler: GNU GCC Compiler)
|line-8|error: 'movieOutput' was not declared in this scope|
Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|`
Bewegen Sie die Definition des Aufrufs main unter der Funktion –
als @JosephYoung schlägt vor oder schreibe eine forward Deklarationszeile für diese Funktion "über" die erste Funktion "Aufruf" es (hier Haupt) – Dilettant
Danke Leute, ihr habt mir geholfen es herauszufinden! – DaltonM