У меня есть этот код ниже, и я получаю сообщение об ошибке при компиляции:
ошибка: невозможно преобразовать' const char * 'в' std :: string * 'для аргумента' 1 'в' void sillyFunction (std :: string *, int) '
#include <iostream>
#include <string>
using namespace std;
int counter = 0;
void sillyFunction(string * str, int cool=0);
int main(){
sillyFunction("Cool");
sillyFunction("Cooler", 1);
return 0;
}
void sillyFunction(string * str, int cool){
counter++;
if (cool){
for (int i=0; i<counter; i++) cout << *str << endl;
} else {
cout << *str << endl;
}
}