public member function
<ios> <iostream>
std::basic_ios::tie get (1)basic_ostream<char_type,traits_type>* tie() const;set (2)
basic_ostream<char_type,traits_type>* tie (basic_ostream<char_type,traits_type>* tiestr);
Get/set tied stream
The first form (1) returns a pointer to the tied output stream.The second form (2) ties the object to tiestr and returns a pointer to the stream tied before the call, if any.
The tied stream is an output stream object which is flushed before each i/o operation in this stream object.
By default,
cinis tied to
cout, and
wcinto
wcout. Library implementations may tie other standard streams on initialization.
By default, the standard narrow streams
cinand
cerrare tied to
cout, and their wide character counterparts (
wcinand
wcerr) to
wcout. Library implementations may also tie
clogand
wclog.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// redefine tied object
#include <iostream> // std::ostream, std::cout, std::cin
#include <fstream> // std::ofstream
int main () {
std::ostream *prevstr;
std::ofstream ofs;
ofs.open ("test.txt");
std::cout << "tie example:\n";
*std::cin.tie() << "This is inserted into cout";
prevstr = std::cin.tie (&ofs);
*std::cin.tie() << "This is inserted into the file";
std::cin.tie (prevstr);
ofs.close();
return 0;
}
tie example: This is inserted into cout
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4