所以我得到了上面提到的错误代码行: “women [count_wc] =(temp );” [错误]不能将'std :: string {aka std :: basic_string}'转换为赋值中的'char' - C++错误不能将'std :: string {aka std :: basic_string <char>}'转换为'char'的赋值 - C++
这是被调用的函数内部。
另外在函数实际被调用的地方发现了另一个错误。错误 “get_comp_women(women,MAX_W,array,ROW);” (std :: string *)(& women)'从'std :: string * {aka std :: basic_string *}'转换为'std :: string {aka std :: basic_string}'的错误代码为 [Error] “
const int MAX_W = 18;
const int MAX_T = 18;
const int MAX_E = 14;
const int ROW = 89;
using namespace std;
struct data
{
string name;
string event;
};
void get_comp_women(string women, int MAX_W, data array[], int ROW)
{
int count_wc = 0;
int count_wn = 0;
int event_occ = 0;
string temp;
temp = (array[0].name);
event_occ = (ROW + MAX_W);
for (int i = 1; i < event_occ; i++)
{
if (temp == array[count_wn].name)
{
women[count_wc] = (temp);
count_wn++;
}
else
{
temp = array[count_wn].name;
count_wc++;
}
}
int main()
{
string women[MAX_W];
data array[ROW];
get_comp_women(women, MAX_W, array, ROW);
}
我认为错误信息应该是不言自明的。阅读它们,并查看函数声明,以及在调用函数时通过的内容。 –
你想要做什么'women [count_wc] =(temp);'? – MikeCAT
将参数类型从'string women'改为'string women []'。 – owacoder