overloading << operator with variable args

is it possible to overload the insertion operator << with variable number of arguments.It would be very
helpful if someone explains with an example.the MS VC++ compiler does not even allow the declation but why??
Who is Participating?
alexoConnect With a Mentor Commented:
No, you cannot.
The reason is that when you overload operators, you can only change the functionality and the types of the arguments, *not* the number of arguments, precedence or associativity.

In other words, the built-in operator<<() takes one argument, so all overloaded operators must follow that convention.
kalvAuthor Commented:
is it possible to write a member function to overload it,i know to do it as a friend.
kalvAuthor Commented:
  if i write it as a friend it takes two args,one for the loperand and the other
for the roperand.but how do you do it as a member function?
kalvAuthor Commented:
please explain me with an example to write it as a member function
kalvAuthor Commented:
iam ready to give 10 points.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.