0

Need help with overloading <<, >> operators for pointers C++

I get segmentation fault when my program runs into this section of my program: ostream& operator<<(ostream& output, TrashCan*& p) { output << "Size = " << p->my_Size << " Contents = " << p->my_Contents << endl; return output; } it runs fine with the regular << >> overload without pointers though

2nd Dec 2016, 5:47 PM
J.C Vega
J.C Vega - avatar
1 Antwort
0
Are you sure that you can use refference and derefference operator at the same time. Try just with &p
2nd Dec 2016, 7:00 PM
Aleksandar
Aleksandar - avatar