开发者

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

开发者 https://www.devze.com 2023-03-28 13:38 出处:网络
ost开发者_JAVA百科ream& tab (ostream &o) { return o << \'\\t\'; } I want to put this declaration in iostream library..how can i do this??You can\'t. The contents of the iostream librar
ost开发者_JAVA百科ream& tab (ostream &o)
{
    return o << '\t';
}

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号