fork(1) download
  1. //
  2. // main.cpp
  3. // ai
  4. //
  5. // Created by Steven Wiseman on 16/06/2026.
  6. //
  7.  
  8. #include <iostream>
  9. #include <list>
  10.  
  11. class BehaviourSeek;
  12. class Actor;
  13.  
  14. class Actor {
  15.  
  16. public:
  17.  
  18. Actor (std::string n) {
  19.  
  20. m_name = n;
  21.  
  22. }
  23.  
  24. std::string m_name;
  25. std::list <BehaviourSeek*> BehaviourList;
  26.  
  27. };
  28.  
  29. class BehaviourSeek {
  30.  
  31. public:
  32.  
  33. BehaviourSeek (Actor* target) {
  34.  
  35. m_target = target;
  36.  
  37. std::cout << "hiya" << std::endl;
  38.  
  39. }
  40.  
  41. Actor* m_target;
  42.  
  43. };
  44.  
  45. int main(int argc, const char * argv[]) {
  46.  
  47. Actor a0 ("Steven");
  48. Actor a1 ("Aleksandra");
  49.  
  50. BehaviourSeek date (a1);
  51.  
  52. a0.BehaviourList.push_back (date);
  53.  
  54. return EXIT_SUCCESS;
  55. }
  56.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main(int, const char**)’:
prog.cpp:50:27: error: no matching function for call to ‘BehaviourSeek::BehaviourSeek(Actor&)’
     BehaviourSeek date (a1);
                           ^
prog.cpp:33:5: note: candidate: ‘BehaviourSeek::BehaviourSeek(Actor*)’
     BehaviourSeek (Actor* target) {
     ^~~~~~~~~~~~~
prog.cpp:33:5: note:   no known conversion for argument 1 from ‘Actor’ to ‘Actor*’
prog.cpp:29:7: note: candidate: ‘constexpr BehaviourSeek::BehaviourSeek(const BehaviourSeek&)’
 class BehaviourSeek {
       ^~~~~~~~~~~~~
prog.cpp:29:7: note:   no known conversion for argument 1 from ‘Actor’ to ‘const BehaviourSeek&’
prog.cpp:29:7: note: candidate: ‘constexpr BehaviourSeek::BehaviourSeek(BehaviourSeek&&)’
prog.cpp:29:7: note:   no known conversion for argument 1 from ‘Actor’ to ‘BehaviourSeek&&’
prog.cpp:52:37: error: no matching function for call to ‘std::__cxx11::list<BehaviourSeek*>::push_back(BehaviourSeek&)’
     a0.BehaviourList.push_back (date);
                                     ^
In file included from /usr/include/c++/8/list:63,
                 from prog.cpp:9:
/usr/include/c++/8/bits/stl_list.h:1219:7: note: candidate: ‘void std::__cxx11::list<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = BehaviourSeek*; _Alloc = std::allocator<BehaviourSeek*>; std::__cxx11::list<_Tp, _Alloc>::value_type = BehaviourSeek*]’
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/8/bits/stl_list.h:1219:7: note:   no known conversion for argument 1 from ‘BehaviourSeek’ to ‘BehaviourSeek* const&’
/usr/include/c++/8/bits/stl_list.h:1224:7: note: candidate: ‘void std::__cxx11::list<_Tp, _Alloc>::push_back(std::__cxx11::list<_Tp, _Alloc>::value_type&&) [with _Tp = BehaviourSeek*; _Alloc = std::allocator<BehaviourSeek*>; std::__cxx11::list<_Tp, _Alloc>::value_type = BehaviourSeek*]’
       push_back(value_type&& __x)
       ^~~~~~~~~
/usr/include/c++/8/bits/stl_list.h:1224:7: note:   no known conversion for argument 1 from ‘BehaviourSeek’ to ‘BehaviourSeek*&&’
stdout
Standard output is empty