-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiostream.cpp
47 lines (39 loc) · 1.11 KB
/
iostream.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include <String>
#include "Log.hpp"
//#define Log std::cout << __FUNCTION__ << "() "
class OverrideInOutStream
{
public:
friend std::ostream& operator << (std::ostream& p_os, const OverrideInOutStream& p_overrideInOutStream);
friend std::istream& operator >> (std::istream& p_is, OverrideInOutStream& p_overrideInOutStream);
void operator << (const std::string& p_input)
{
m_value = p_input;
}
private:
std::string m_value{"Member Initialized"};
};
std::ostream& operator <<(std::ostream& p_os, const OverrideInOutStream& p_overrideInOutStream)
{
return p_os << p_overrideInOutStream.m_value;
}
std::istream& operator >>(std::istream& p_is, OverrideInOutStream& p_overrideInOutStream)
{
return p_is >> p_overrideInOutStream.m_value;
}
void testInputOutputOverride()
{
OverrideInOutStream l_io;
Log << l_io;
LogStream()<< "hwllo";
//Log << l_io;
l_io << "input with input stream";
//Log << l_io;
}
int main(int argc, char const *argv[])
{
std::cout << "Hello, great first step" << std::endl;
testInputOutputOverride();
return 0;
}