Итак, я очень новичок в этом, и я пытаюсь создать программу, которая будет рассчитывать стоимость любого количества междугородних звонков. Я еще не продвинулся очень далеко, я застрял, пытаясь понять, как заставить функцию повторяться. Прямо сейчас я получаю сообщение об ошибке
Строка 18: здесь не допускается определение функции перед токеном '{' и ожидаемым ',' или ';' перед токеном '{'.
Строка 18 – это строка сразу после void costCalc(int numCalls)
.
Вот мой код:
#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()
вышеmain()
. - person twalberg   schedule 05.02.2014C
? Я не видел ниusing namespace std;
, ниcin
, ниcout
ни в одномC
источнике... (поправьте меня, если я ошибаюсь. Я тожеC
новичок) - person core1024   schedule 05.02.2014C
; этоC++
. Потоки не поддерживаются вC
. - person Stephen Rasku   schedule 05.02.2014