0
我需要得到'< <'和'>>'來爲指針工作,因爲我已經在主要代碼中爲我的驅動編碼了。如何實現<< and >>爲指針?
int main()
{
using namespace std;
cout << "Welcome to My TrashCan Program!" << endl;
TrashCan myCan;
TrashCan yourCan;
TrashCan empty(0, 0);
TrashCan * ptrCan = new TrashCan(0, 0);
TrashCan * nullCan = NULL; // pointer to null
// using pointers here
cin >> ptrCan;
cin >> nullCan; //
cout << ptrCan << endl;
cout << nullCan << endl; //
return 0;}
林假設我將不得不某處實現這些功能,但我不太清楚如何:
friend std::ostream& operator <<(std::ostream& outs, const TrashCan * drive);
friend std::istream& operator >>(std::istream& ins, TrashCan * & drive);
你在技術上不允許這樣做。 – chris
我們輸入的是什麼被加載到指針中。地址? – Radnyx