given the code segment below
void main()
{
cout<<"my no. is";
}
question is how can we get the output hai aravind my no. is
99999999999 without editig the main().

Answer Posted / sunil chopra

Overload the << operator.

ostream& operator << (ostream& ot, const char* chr)
{
using std::operator<<;
return ot << "Hai Arvind " << chr << " 99999999999";
}

Is This Answer Correct ?    9 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is pointer with example?

560


Write a program using merge () function to combine the elements of array x[ ] and y[ ] into array z[ ].

601


How many namespaces are there in c++?

556


What are advantages of using friend classes?

631


What is meant by iomanip in c++?

604






What is the use of endl?

545


What are stacks? Give an example where they are useful.

592


What is the extraction operator and what does it do?

612


What is c++ and its uses?

622


What are the storage qualifiers?

661


How to demonstrate the use of a variable?

642


State the difference between pre and post increment/decrement operations.

606


Explain about Garbage Collector?

646


What are the three forms of cin.get() and what are their differences?

629


What do manipulators do?

568