Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put our own function declaration in iostream library in c++?

ostream& tab (ostream &o)
{
    return o << '\t';
}

I want to put this declaration in iostream library..how can i do this??

like image 589
shubhendu mahajan Avatar asked Aug 14 '11 14:08

shubhendu mahajan


People also ask

Can you use iostream in C?

There is no analog to iostream in C -- it lacks objects and types. If you're using C++, it's the analog to <cstdio> .

Is iostream in C or C++?

C++ input/output streams are primarily defined by iostream , a header file that is part of the C++ standard library (the name stands for Input/Output Stream). In C++ and its predecessor, the C programming language, there is no special syntax for streaming data input or output.

How do you define iostream in C++?

iostream: iostream stands for standard input-output stream. This header file contains definitions of objects like cin, cout, cerr, etc. iomanip: iomanip stands for input-output manipulators. The methods declared in these files are used for manipulating streams.


1 Answers

You can't. The contents of the iostream library are defined by the C++ standard, and potentially shared by every C++ program in the system. Although you can (in practice, this is technically forbidden by the standard) inject things into the std namespace for your own program (this is a bad idea however due to potential name collisions), and you can define things in your own libraries, you can't just go around modifying common libraries for everyone.

like image 53
bdonlan Avatar answered Oct 27 '22 11:10

bdonlan