Make sure your testcase is self-contained and actually reproduces the problem
First snip, I guess that you are defining it as a member function.
So you end with 3 objects: the stream `s', the arraylist `a' and the arraylist *this
Second snip, I don't believe that the error message refers to that snip, but to its usage.
You were trying to do, by instance, std::cout << foo; but the code is for doing foo << std::cout;
2. Avoid making friends. If your type T has sufficient public interface, then non-friends can extract necessary values.
It seems that you need a templated operator<< the ArrayList family of types and a concrete operator<< for Account as (presumably) you try to print an Arraylist<Account> object.
I looked at the link kesk gave me, and it didn't exactly help. I know what might cause a linker error now, but I always put class definitions in the header files. I also included the header file in all of my other files. What else might cause a linker error.
The overloaded operator needs to define both arguments (on the right and left side of <<):
I've figured that much out, but that doesn't help me fix the compiler error I get when I don't include the friend modifier. The compiler assumes that it's a member function and demands it only have one argument.
How do I know if I don't have sufficient public interfaces?
Now that the << operator is not a member of the class it can only access the public members. So can it access everything it needs to? If not then you can do the pass-through method that I mentioned.