【发布时间】:2012-10-05 18:00:58
【问题描述】:
我在尝试学习 C++ 时一直在玩指针和动态内存,但我在编译时不断收到此错误。
error C2678: binary '>>' : no operator found which takes a left-hand operand of type 'std::istream' (or there is no acceptable conversion)
我的代码如下:
int * ageP;
ageP = new (nothrow) int;
if (ageP == 0)
{
cout << "Error: memory could not be allocated";
}
else
{
cout<<"What is your age?"<<endl;
cin>> ageP; <--this is the error line
youDoneIt(ageP);
delete ageP;
}
有什么想法吗?提前感谢您的帮助。
【问题讨论】:
标签: c++ visual-c++ pointers io dynamic-memory-allocation