nested_vcall_test.cc 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // { dg-do run }
  2. class EtherCtrl {
  3. protected:
  4. int ssap;
  5. public:
  6. EtherCtrl(void);
  7. ~EtherCtrl();
  8. virtual int getSsap(void) const;
  9. virtual void setSsap(int);
  10. };
  11. class EtherFrameWithLLC {
  12. protected:
  13. int ssap;
  14. public:
  15. EtherFrameWithLLC(const char *, int);
  16. ~EtherFrameWithLLC();
  17. virtual int getSsap(void) const;
  18. virtual void setSsap(int);
  19. };
  20. EtherCtrl::EtherCtrl()
  21. {
  22. this->ssap = 0;
  23. }
  24. EtherCtrl::~EtherCtrl()
  25. {
  26. }
  27. int EtherCtrl::getSsap() const
  28. {
  29. return ssap;
  30. }
  31. void EtherCtrl::setSsap(int ssap)
  32. {
  33. this->ssap = ssap;
  34. }
  35. EtherFrameWithLLC::EtherFrameWithLLC(const char *name, int kind)
  36. {
  37. this->ssap = 0;
  38. }
  39. EtherFrameWithLLC::~EtherFrameWithLLC()
  40. {
  41. }
  42. int EtherFrameWithLLC::getSsap() const
  43. {
  44. return ssap;
  45. }
  46. void EtherFrameWithLLC::setSsap(int ssap)
  47. {
  48. this->ssap = ssap;
  49. }
  50. int
  51. main (int argc, char **argv)
  52. {
  53. EtherCtrl *etherctrl = new EtherCtrl ();
  54. EtherFrameWithLLC *frame = new EtherFrameWithLLC ("test", 10);
  55. int my_value;
  56. etherctrl->setSsap(43);
  57. frame->setSsap(etherctrl->getSsap());
  58. my_value = frame->getSsap();
  59. return 0;
  60. }