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

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

shubhendu mahajan
  • 816
  • 1
  • 7
  • 16
  • 2
    Why would you want to do that? Why not add it in your own project? – Antti Aug 14 '11 at 14:12
  • 2
    Don't do this. Don't try to do this. Don't desire to do this. – Lightness Races in Orbit Aug 14 '11 at 14:20
  • Are you actually wanting it to become "part of" the standard library on your system, or are you just wanting it to work in your project? To phrase it another way, what is the actual problem you have right now using the code you posted? – John Zwinck Aug 14 '11 at 14:21
  • I know how to add it in my program but i just want to know how can i make it a part of the standard library on my system??..please suggest – shubhendu mahajan Aug 14 '11 at 14:31
  • @desprado07: What does that _mean_? "Part of the standard library on my system?" Please answer John's question. Ultimately I think the answer to this question is going to remain what I said above: "no, and don't try". – Lightness Races in Orbit Aug 14 '11 at 14:48
  • 1
    @tomalak: u r trying to say that their is no way to add our own function declaration in a standard library..i don't beleive this..Dennis Ritchie or Bjarne Stroustrup can't be that much protective.. – shubhendu mahajan Aug 14 '11 at 15:00
  • @desprado07: "Dennis Ritchie or Bjarne Stroustrup" have nothing to do with it. The standard prohibits you from doing this, and that is all there is to it. Furthermore, why on earth would you want to? – Lightness Races in Orbit Aug 14 '11 at 15:01

1 Answers1

6

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.

bdonlan
  • 224,562
  • 31
  • 268
  • 324
  • 9
    The standard explicitly forbids adding declarations into std namespace - only specializations of templates for user defined types. – Armen Tsirunyan Aug 14 '11 at 14:16