Sorry for the delay in responding. I went back through the program and driver file, and had a whole slew of issues crop up. Namely, I was attempting to use vector operations (like items.end()) and such that my computer just really did NOT like. However, I have gotten those resolved (I hope...I only have a warning comparing int i to items.size() ). I'm just iterating through the vector as if it were an array.
Now, I am back to the original issue - 1 unresolved external symbol.
I have the following line declared in my class, before all other declarations
friend ostream& operator <<(ostream&, const myClass<T>&)
At the end of the header file, since I'm defining my functions in the same file instead of a separate .cpp file, I have
1 2 3 4 5 6 7 8 9 10 11
|
template <class T>
ostream& operator <<(ostream& out, const myClass<T>& list) {
for(int i = 0;i < list.items.size();++i) {
if(i == 0)
out << list.items[i];
else
out << " " << list.items[i];
}
return out;
}
|
In the driver program, I have the following line of code:
cout << list
Where "list" is an object of class myClass.
I'm under the impression that a friend function can access protected members of the class, and items is a protected member of the class. I know I have to pass an ostream object by reference, as well as an object of what I want outputted. I believe I have kept both of these standards intact...however I
have spent the better part of the evening running from funnel clouds...