Oke jadi saya sangat baru dalam hal ini dan saya mencoba membuat program yang akan menghitung biaya sejumlah panggilan jarak jauh. Saya belum melangkah terlalu jauh, saya terjebak dalam mencoba mencari cara agar fungsi tersebut terulang kembali. Saat ini saya mendapat pesan kesalahan
Baris 18 definisi fungsi tidak diperbolehkan di sini sebelum '{' token dan diharapkan ',' atau ';' sebelum tanda '{'.
Baris 18 adalah garis tepat setelah void costCalc(int numCalls)
Ini kode saya sejauh ini:
#include<iostream>
using namespace std;
int main()
{
// Declare and initialize all variables
int numCalls = 0;
int length = 0;
int hour = 0;
char day = ' ';
char dest = ' ';
double cost = 0.0;
cout<<"Enter the number of calls: ";
cin>>numCalls;
void costCalc(int numCalls)
{
if (numCalls > 0)
{
cout<<"Enter length of call in minutes: ";
cin>>length;
costCalc(numCalls-1);
}
}
// Request the number of calls from the user
// Loop for the requested number of calls:
// Request the user to give you the call length,
// call day of week and hour of call, and call
// destination
// Instantiate and initialize a Call object
// using either
// a) the 4-parameter constructor, OR
// b) the default constructor and each of the
// set member functions.
// Get the cost of the call using the calcCallCost
// function and add it to the total cost of the calls.
// Use the callMsg function to print a message about the call
// end loop
// Report the total cost of all the calls.
system("pause");
return 0;
}
costCalc()
Anda ke atasmain()
. - person twalberg   schedule 05.02.2014C
sama sekali? Saya belum pernah melihatusing namespace std;
baikcin
ataucout
di dalamC
sumber mana pun... (koreksi saya jika saya salah. SayaC
pemula juga) - person core1024   schedule 05.02.2014C
; ituC++
. Streaming tidak didukung diC
. - person Stephen Rasku   schedule 05.02.2014