Compare Pastes

Differences between the pastes #134205 (05.05.2020 14:29) and #134206 (05.05.2020 14:41).
11#include
22
33class type_one
44{
55};
66
77class type_two
88{
99};
1010
1111class i_one
1212{
1313public:
1414 virtual void set (const type_one & val, int id) = 0;
1515};
1616
1717class i_two
1818{
1919public:
2020 virtual void set (const type_two & val) = 0;
2121};
2222
2323
2424
2525class i_one_two:public i_one, public i_two
2626{
27
};
28
27
28
// = = = = = = >>> Вот решение
2929
30
class OneTwo:public i_one_two
31
{
32
public:
33
  void set (const type_one & val, int id)
34
  {
35
    std::cout << "type_one value, id = " << id;
36
  }
37
38
  void set (const type_two & val)
39
  {
40
    std::cout << "type_two value\n";
41
  }
42
};
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
  }
4343
44
45
int
46
main ()
47
{
48
  OneTwo ot;
44
  void set (const type_two & val)
45
  {
46
    std::cout << "type_two value\n";
47
  }
48
};
4949
50
  i_one_two *i12 = &ot;
51
52
  i12->set(type_one (), 111); // error: request for member ‘set’ is ambiguous
53
  i12->set(type_two ());      // error: request for member ‘set’ is ambiguous
54
  return 0;
55
}
56
57
//==============================
58
main.cpp: In function ‘int main()’:
59
main.cpp:52:8: error: request for member ‘set’ is ambiguous
60
   i12->set(type_one (), 111);
61
        ^~~
62
main.cpp:20:16: note: candidates are: virtual void i_two::set(const type_two&)
63
   virtual void set (const type_two & val) = 0;
64
                ^~~
65
main.cpp:14:16: note:                 virtual void i_one::set(const type_one&, int)
66
   virtual void set (const type_one & val, int id) = 0;
67
                ^~~
68
main.cpp:53:8: error: request for member ‘set’ is ambiguous
69
   i12->set(type_two ());
70
        ^~~
71
main.cpp:20:16: note: candidates are: virtual void i_two::set(const type_two&)
72
   virtual void set (const type_two & val) = 0;
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;
7373 ^~~
74
main.cpp:14:16: note:                 virtual void i_one::set(const type_one&, int)
75
   virtual void set (const type_one & val, int id) = 0;
76
                ^~~
77
78
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