当我尝试学习 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;
}
有任何想法吗?在此先感谢您的帮助。