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

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

1. 报错

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

2. 原因

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

3.解决办法

使用cout << str

4.注

同样的问题有:

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

你可能感兴趣的:(#,C/C++)