-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnvi.cpp
More file actions
41 lines (34 loc) · 707 Bytes
/
nvi.cpp
File metadata and controls
41 lines (34 loc) · 707 Bytes
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
#include <iostream>
struct base
{
void read_from(std::istream &in)
{
read_from_impl(in);
}
void write_to(std::ostream &out)
{
write_to_impl(out);
}
virtual ~base() = default;
private:
virtual void read_from_impl(std::istream &) = 0;
virtual void write_to_impl(std::ostream &) = 0;
};
struct derived : base
{
private:
void read_from_impl(std::istream &in) override
{
std::cout << "read_from_derived_impl" << std::endl;
}
void write_to_impl(std::ostream &out) override
{
std::cout << "write_to_derived_impl" << std::endl;
}
};
int main()
{
derived d;
d.read_from(std::cin);
d.write_to(std::cout);
}