【发布时间】:2017-10-20 04:43:51
【问题描述】:
我正在尝试学习 C++,并且正在创建一些小程序来测试它是如何工作的。我编写了这段代码,但由于某种原因,我在编译时遇到了这个错误:
binary '>>': no operator found which takes a left-hand operand of type 'std::istream' (or there is no acceptable conversion)
如果有人能帮我解决这个问题,我将不胜感激。
代码:
#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include <string>
#include "logo.h"
class classTest
{
public:
void setName(std::string x)
{
name = x;
}
std::string getName()
{
return name;
}
private:
std::string name;
};
int main()
{
SetConsoleTitle("plains.exe");
displayLogo();
std::cout << "Please enter your name: ";
classTest testObject;
std::cin >> testObject.setName;
std::cout << "Your name is " << testObject.getName() << "." << std::endl;
return 0;
}
【问题讨论】:
标签: c++ class object operators