Given the initial comments posted to the thread, I expected this thread to die, but it has not. I thought that moderator might move the thread to the General thread, but it is still here, so....

You can directly call a method for a specific class in C++ providing you have visibility to see the class and the method in the class. The example that I provided to the original poster using a direct email is as follows:

Qt Code:
  1. class LTop
  2. {
  3. public:
  4. virtual void notInMid() const
  5. {
  6. qDebug("Method LTop::notInMode()");
  7. }
  8. virtual void allDo() const
  9. {
  10. qDebug("Method LTop::allDo()");
  11. }
  12. };
  13. class LMid : public LTop
  14. {
  15. typedef LTop Base;
  16. public:
  17. virtual void allDo() const
  18. {
  19. Base::allDo();
  20. qDebug("Method LMid::allDo()");
  21. }
  22. };
  23. class LBottom : public LMid
  24. {
  25. typedef LMid Base;
  26. public:
  27. virtual void notInMid() const
  28. {
  29. //Cannot make this call because it does not exist
  30. //Base::notInMid();
  31. //Only works if there is public inheritance.
  32. LTop::notInMid();
  33. qDebug("Method LBottom::notInMode()");
  34. }
  35. virtual void allDo() const
  36. {
  37. //this->LMid::allDo();
  38. Base::allDo();
  39. qDebug("Method LBottom::allDo()");
  40. }
  41. };
To copy to clipboard, switch view to plain text mode 

Notice a few things that allow this to work

  1. Public inheritance is used. Using "class LMid : LTop" rather than "class LMid : public LTop" prevents LBottom from referencing a method in LTop, but still allows LMid to reference LTop.
  2. The methods must have visibility. In this example, I used public:
  3. You cannot call a method directly that does not exist. Consider the method "notInMid". The method is not implemented in LMid. I dislike that in LBottom I cannot simply say "call the next one up in the heirarchy". I am sure that this is because C++ supports multiple inheritance, so it is not obvious what to call unless you explicitly specify it.

The probably enough for now.