我定义了这个类:
class Forum{
std::string title;
Thread* threads[5];
Run Code Online (Sandbox Code Playgroud)
在Forum :: Forum的构造函数中,我想传递一个字符串参数来定义title(它是type-string)
Forum::Forum(string *k) {
int i;
std::strcpy(&title.c_str(),k->c_str());
Run Code Online (Sandbox Code Playgroud)
我有问题.在这段代码中我得到一个"左值作为一元'和'操作数'错误.如果我擦除'&'我得到错误"无效转换'const char*'到'char*'[-fpermissive]".
任何想法我将如何设置将strcpy(或其他方法可能)的参数传递给字符串类型避免上述错误?