error C2679

来源:互联网 发布:现代商友软件 编辑:程序博客网 时间:2024/05/16 10:38
#include<conio.h>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;

 
 
int main()
{
    const string str1 = "Mary and Linda";
    const string str2 = " are friends.";
 
    string str = str1;
    str += str2;
    std::cout<<str<<endl;
    getch();
    return 0;

}

提示错误:

新建文本文档.cpp
C:\Users\WUQ\Desktop\c++ plus\新建文本文档.cpp(16) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no ac
ceptable conversion)
Error executing cl.exe.



删除#include<cstring>中的c即可解决

0 0
原创粉丝点击