"Основи на програмирането със C++"/Глава 10 Функции Задача: известия
https://cpp-book.softuni.bg/chapter-10-functions.html
Дава ми грешка: undefined reference to 'readAndProcessMassage()'
Защо?
void showSuccessMassage(string operations, string massage);
void showWarningMassage(string massage);
void showErrorMassage(string operations, string massage, string errorCode);
void readAndProcessMassage();
int main(){
int N;
cin >> N;
for (int i=0; i<N; i++){
readAndProcessMassage();
}
return 0;
}
void showSuccessMassage(string operations, string massage){
cout << "Successfully executed " << operations << "." << endl;
string line = "Successfully executed " + operations + ".";
int length = line.size();
cout << string(length, '=') << endl;
cout << massage << "." << endl;
}
void showWarningMassage(string massage){
cout << "Warning: " << massage << "." << endl;
string line = "Warning: " + massage + ".";
int length = line.size();
cout << string(length, '=') << endl;
cout << massage << "." << endl;
}
void showErrorMassage(string operations, string massage, string errorCode){
cout << "Error: Failed to execute " << operations << "." << endl;
string line = "Error: Failed to execute " + operations + ".";
int length = line.size();
cout << string(length, '=') << endl;
cout << "Reason: " << massage << "." << endl;
cout << "Error code: " << errorCode << "." << endl;
}
void readAndProcessMassage(string massageType){
cin >> massageType;
if (massageType=="success"){
string successOperation, successMassage;
cin >> successOperation >> successMassage;
showSuccessMassage(successOperation, successMassage);
}
else if (massageType == "warning"){
string massageWarning;
cin >> massageWarning;
showWarningMassage(massageWarning);
}
else if (massageType=="error"){
string errorOperation, errorMassage, errorCode;
cin >> errorOperation >> errorMassage >> errorCode;
showErrorMassage(errorOperation, errorMassage, errorCode);
}
}
Благодаря, за пореден път, за помощта. Мисля, че си оправих грешките и според мен програмата работи коректно, но judge не ми дава точки. Не мога да разбера защо.
#include<iostream>
#include<string>
using namespace std;
void showSuccessMassage(string operations, string massage);
void showWarningMassage(string massage);
void showErrorMassage(string operations, string massage, string errorCode);
void readAndProcessMassage(string massageType);
int main(){
int N;
cin >> N;
for (int i = 0; i <= N; i++){
string massageType;
getline(cin, massageType);
readAndProcessMassage(massageType);
}
return 0;
}
void showSuccessMassage(string operations, string massage){
cout << "Successfully executed " << operations << "." << endl;
string line = "Successfully executed " + operations + ".";
int length = line.size();
cout << string(length, '=') << endl;
cout << massage << "." << endl;
}
void showWarningMassage(string massage){
cout << "Warning: " << massage << "." << endl;
string line = "Warning: " + massage + ".";
int length = line.size();
cout << string(length, '=') << endl;
}
void showErrorMassage(string operations, string massage, string errorCode){
cout << "Error: Failed to execute " << operations << "." << endl;
string line = "Error: Failed to execute " + operations + ".";
int length = line.size();
cout << string(length, '=') << endl;
cout << "Reason: " << massage << "." << endl;
cout << "Error code: " << errorCode << "." << endl;
}
void readAndProcessMassage(string massageType){
if (massageType == "success"){
string successOperation, successMassage;
getline(cin, successOperation);
getline(cin, successMassage);
showSuccessMassage(successOperation, successMassage);
}
else if (massageType == "warning"){
string massageWarning;
getline(cin, massageWarning);
showWarningMassage(massageWarning);
}
else if (massageType == "error"){
string errorOperation, errorMassage, errorCode;
getline(cin, errorOperation);
getline(cin, errorMassage);
getline(cin, errorCode);
showErrorMassage(errorOperation, errorMassage, errorCode);
}
}