Reputation: 273
can i overload cout? just use the same code in main here
using namespace std;
int main() {
cout << “overload" <<endl;
return 0;
}
is it possible to overload << here? For example let the program prints "overload operator" instead of "overload"?
Upvotes: 1
Views: 165
Reputation: 128
cout
is just an object in namespace std
.
If your "overload" means using the same code to do other things, you can create a namespace
on your own, create an instance named cout
, then override the <<
operator.
Upvotes: 1