KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to do it this way: template <typename T> ostream &operator<<(ostream &os, T &arr) { /*...*/ } But can T represent an array? Is it correct to overload the << operator for an array? EDIT: According to Kerrek SB's advice, here is my implementation for << : template <typename T, unsigned int N> ostream &operator<<(ostream &os, const T (&arr)[N]) { int i; for(i = 0; i < N; i++) os << arr[i] << " "; os << endl; return os; } Is my implementation right? I got a compilation error.
Tags (comma-separated)
Save Edits
Cancel