fork download
  1. #include <stdio.h>
  2.  
  3. class Collection {
  4. public:
  5. Collection() {
  6. }
  7. virtual ~Collection() {
  8. }
  9. virtual void add(const Collection& c) {
  10. printf("Added c elements here\n");
  11. }
  12. };
  13. class Set: public Collection {
  14. public:
  15. Set() {
  16. }
  17. virtual ~Set() {
  18. }
  19. };
  20. class SortedSet: public Set {
  21. public:
  22. SortedSet() {
  23. }
  24. virtual ~SortedSet() {
  25. }
  26. };
  27.  
  28. int main(){
  29. Set *s = new Set();
  30. SortedSet *ss = new SortedSet();
  31. ss->add(*s);
  32. return 0;
  33. }
  34.  
Success #stdin #stdout 0s 2984KB
stdin
Standard input is empty
stdout
Added c elements here