我正在玩指針和動態內存,因爲我試圖學習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;
}
任何想法?先謝謝您的幫助。
謝謝 - 真的。我正在編輯這個名字......現在我有天賦了。 –