c++ - Why can I not pass my class pointer to my visitor class? It says there are no matching functions -


Essentially this visitor class was working until I tried to add it to another class.

This visitor class I'm going to mention:

Visitor.h
  #ifndef Visitor_h__ #define Visitor_h__ #include & lt; Stdint.h & gt; #include & lt; String & gt; # Include & lt; Vector & gt; Namespace Ph2_System {class SystemController; } Namespace GUI {class SystemControllerWorker; } Class HwDescriptionVisitor {public: // SystemController Virtual Zero Travel (Ph2_System :: SystemController and pSystemController) {} // This is a / system controller worker Virtual Wide Visit (GUI :: SystemControllerWorker and pSystemControllerWorker) {} >  

This is the class that attempts to call a visit to it:

SystemControllerWorker.h
  #include "../HWInterface /Visitor.h "#include" model / settings.h "Namespace GUI {class SystemControllerWorker {public: SystemControllerWorker (settings and configuration); ~ SystemControllerWorker (); Acceptance (HwDescriptionVisitor and pVisitor) const {pVisitor.visit (* this); // This is where I (auto & amp; cShelve: fShelveVector) cShelve- & gt; Receive my error message for the pVisitor; } Private: setting & amp; M_Settings; / /   

SystemController and SystemControllerWorker between the top & amp; In config, the first one does not take any of the logic, and it does one by any idea why I get this error message:

  Error: to call "HwDescriptionVisitor :: There is no matching function for "visit (const GUI :: SystemControllerWorker & amp; PVisitor.visit (* this);   

Or what could that mean?

Sometimes it is good to read the entire error message, a compiler can really understand your Ready to help why it needs to fail:

  main.cpp: Member Function 'Zero System Controller Worker :: Acceptance (HWuscriptVisitor & amp;) Constant': Main.cpp: 15: 29: Error: No matching function for calling 'HwDescriptionVisitor :: visit (const SystemControllerWorker & amp;)' pVisitor.visit (* this) to make calls; ^ Main.cpp: 15: 29: Note: The candidate is: main.cpp: 8: 10: Note: Empty HwDescriptionVisitor: visit (SystemControllerWorker & amp;) Zero Travel (SystemControllerWorker and pSystemControllerWorker) {} ^ main.cpp: 8: 10: Note: 'System Controller Worker & amp; There is no known conversion for Logic 1.   

This last note is the most important; It says: " 'const systemcontrollerworker' to 'SystemControllerWorker & amp; No known conversion for argument 1

You might think that this a const SystemControllerWorker < / Code> is type, not just SystemControllerWorker . The reason for this is that the call pVisitor.visit (* this) is const (HwDescriptionVisitor and pVisitor) const {// right here ~~~~ ^

this It creates an indicator for const SystemControllerWorker and Dereferencing resulting in a cons T is also the type.

What should be allowed to do, you can remove const accept member function

OR

Ability const to < SystemController & amp; visit Parameter of member function, like the following:

  Virtual Zero Travel (Console File System :: System Controller and PSITC Controller) {} / here ~~~~ ^    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -