zl程序教程

您现在的位置是:首页 >  其它

当前栏目

[Error] cannot pass objects of non-trivially-copyable type 'std::string {aka class std::basic_string

Error string of Cannot type Class Non Basic
2023-09-14 09:13:18 时间

[Error] cannot pass objects of non-trivially-copyable type 'std::string {aka class std::basic_string<char>}' through '...'

1. 报错

[Error] cannot pass objects of non-trivially-copyable type 'std::string {aka class std::basic_string<char>}' through '...'

2. 原因

不应该使用printf输出一个String类型的字符串

3.解决办法

使用cout << str

4.注

同样的问题有:

  • 使用scanf【c语言】输入string【c++】的对象。这个也会引起程序的崩溃