我不能让这个程序正确编译。这是一个单独链接的程序。这个特殊的功能给我垃圾没有转换的东西在字符串中,但我看不到它。我得到了一个人的帮助,他告诉我要解决另一个问题,这个函数必须接受字符串而不是char *。我想我修复了所有与用字符串替换char *有关的错误,但我似乎无法修复这最后一个错误。请请帮助我! 这里的问题是功能:为什么我会收到错误:无法将'std :: string {aka std :: basic_string <char>}'转换为'char *'赋值?
List_Node *listTextEditor::create_node(string value)//creates the list elements
{
struct List_Node *tempNode, *s;
tempNode = new(struct List_Node);
if (tempNode == NULL)
{
cout << "Memory not allocated " << endl;//if theres nothing in the list
return 0;
}
else
{
tempNode->textLine=value ; //This puts stuff in the current node and creates/moves to the next. THIS IS WHERE THE PROBLEM IS!!!!!!!!!
tempNode->nextEle = NULL;
return tempNode;
}
}
是textLine一个字符串类的成员数据? – Raindrop7
没有从'std :: string'到(可变)'char *'的隐式转换。另外,与你的问题无关:'if(tempNode == NULL)'永远不能评估为'true'。看看[新操作员](http://en.cppreference.com/w/cpp/memory/new/operator_new)是做什么的。 – IInspectable
添加你的类的示例接口 – Raindrop7