For some reason when I overload operators << and >> in my linked, that I will be using for my inventory system, I am unable to access the private members of my list within the overloaded operator? I can't even access the linkedlist that was passed in by reference's members. Maybe I am doing something wrong with the overloading?
I'm not getting an error it's just that something is weird within the overloaded operators>> and <<. Like when I want to access one of the private members within my linked list class I am unable to. I can't use a this-> pointer either to get private members. Nor can i use the referenced list to get the private members. Instead I only get the public function not the private variables when I try to access it.
Perhaps it has to do with operator << taking a std::ostream by value instead of reference. The linkedlist parameter should be const as well.
No, you won't be able to use the this pointer. It's not a member function, but it is a friend so you will be able to access private members (although you shouldn't need it at all if the class has a reasonable public interface.)
Maybe, although I'd like to be able to display all of the contents via the overloaded << operator. And well I can't do that because I can't acess the head pointer. Although, I could have a function that return the head pointer and then iterate through that although what do you think? Is that a good or bad idea?
@Cire Man I'm so dumb. I didn't even notice I was taking the istream and ostream by value rather than by reference. I thought I did that in the first place. I thought you missed something...Facepalm... Anyways scrap what I said earlier. Thanks cire you always got my back.