我有:string ipAddress;
当我尝试:cin>>ipAddress;
我得到
Error 1 error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion) c:\users\r\documents\visual studio 2013\projects\chat\chat\chat.cpp 158 1 Chat
如何更换此说明?
接头:
#include "stdafx.h"
#include "Socket.h"
#include <iostream>
#include <winsock2.h>
#pragma comment(lib, "Ws2_32.lib")
using namespace std;
答案 0 :(得分:3)
尝试通过以下方式包含std::string
的函数声明:
#include <string>
答案 1 :(得分:-1)
使用std :: getline http://www.cplusplus.com/reference/string/string/getline/
string ipAddress
std::getline(cin, ipAddress);