error C2679
来源:互联网 发布:常用nosql数据库 编辑:程序博客网 时间:2024/05/21 13:27
问题:
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 acceptable conversion)
源代码:
#include<iostream>
using namespace std;
class Student
{
int n;
string name;
public:
void set( string str )
{
static int number = 0;
name = str;
n = ++number;
}
void print() { cout<<name<<" -> students are "<<n<<" numbers\n"; }
};
void fn()
{
Student s1;
s1.set("Jentt");
Student s2;
s2.set("Hank");
s1.print();
}
int main()
{
Student s;
s.set("Smith");
fn();
s.print();
return 0;
}
解决:程序开始加上
#include <string>
0 0
- error C2679
- error C2679
- error C2679: binary '>>'
- vs2010 error c2679 binary
- error C2679: binary '<<' : no operator found 解决办法
- VC编译器下如何解决error C2679、error C2676、error C2784、fatal error C1903错误
- error C2679: binary ',class std::allocator >' (or there is no accept
- 重载"&amp;gt;&amp;gt;"时遇到的错误error C2679
- error C2679: 二进制“”类型的右操作数的运算符(或没有可接受的转换)
- error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::wstring'
- error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string'
- error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string'
- error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::wstring'
- error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class Stude
- error C2679: binary '<<' : no operator defined which takes a right-hand operand of type '' (or there is no acceptable conversion
- error C2679: binary '<<' : no operator defined which takes a right-hand operand of type '' (or there is no acceptable conversion
- 错误1error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::str
- 解决 C++错误 error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class CString' (or there is no
- LeetCode - 448. Find All Numbers Disappeared in an Array
- C++的一个错误
- C++ :函数中无需改变传入参数的值时,定义时把 “Item & x ” 都改成 \"const Item & x\"
- c++:error C2593: \'operator <<\' is ambiguous
- error C2512: \'CSample\' : no appropriate default constructor available
- error C2679
- error LNK2001
- Ubuntu安装webpack
- error C2541: delete : cannot delete objects that are not pointers
- C++词汇解析集锦 编程开发人员必备
- c的一些函数(转)
- Debug error错误
- 自加自减运算符
- C语言问题:这个值不是100么,怎么变成15