Compare Pastes

Differences between the pastes #134206 (05.05.2020 14:41) and #266187 (24.10.2022 14:53).
1
#include 
1
 Will Sanctions Against Russia End the War in Ukraine?The New Yorker plsHelpUkraine10202224 
2
3
class type_one
4
{
5
};
6
7
class type_two
8
{
9
};
10
11
class i_one
12
{
13
public:
14
  virtual void set (const type_one & val, int id) = 0;
15
};
16
17
class i_two
18
{
19
public:
20
  virtual void set (const type_two & val) = 0;
21
};
22
23
24
25
class i_one_two:public i_one, public i_two
26
{
27
28
// = = = = = = >>> Вот решение
29
30
//public:
31
//    virtual void set (const type_one & val, int id) = 0;
32
//    virtual void set (const type_two & val) = 0;
33
};
34
35
36
class OneTwo:public i_one_two
37
{
38
public:
39
  void set (const type_one & val, int id)
40
  {
41
    std::cout << "type_one value, id = " << id;
42
  }
43
44
  void set (const type_two & val)
45
  {
46
    std::cout << "type_two value\n";
47
  }
48
};
49
50
51
int
52
main ()
53
{
54
  OneTwo ot;
55
56
  i_one_two *i12 = &ot;
57
58
  i12->set(type_one (), 111); // error: request for member ‘set’ is ambiguous
59
  i12->set(type_two ());      // error: request for member ‘set’ is ambiguous
60
  return 0;
61
}
62
63
//==============================
64
main.cpp: In function ‘int main()’:
65
main.cpp:52:8: error: request for member ‘set’ is ambiguous
66
   i12->set(type_one (), 111);
67
        ^~~
68
main.cpp:20:16: note: candidates are: virtual void i_two::set(const type_two&)
69
   virtual void set (const type_two & val) = 0;
70
                ^~~
71
main.cpp:14:16: note:                 virtual void i_one::set(const type_one&, int)
72
   virtual void set (const type_one & val, int id) = 0;
73
                ^~~
74
main.cpp:53:8: error: request for member ‘set’ is ambiguous
75
   i12->set(type_two ());
76
        ^~~
77
main.cpp:20:16: note: candidates are: virtual void i_two::set(const type_two&)
78
   virtual void set (const type_two & val) = 0;
79
                ^~~
80
main.cpp:14:16: note:                 virtual void i_one::set(const type_one&, int)
81
   virtual void set (const type_one & val, int id) = 0;
82
                ^~~
83
84