fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template <class T>
  5. class Some {
  6. public:
  7. Some(T* other) : ptr(other) { }
  8.  
  9. template <typename R>
  10. Some(const Some<R>& other) {
  11. ptr = dynamic_cast<T*>(other.ptr);
  12. }
  13.  
  14. T* operator->() const { return ptr; }
  15.  
  16. public:
  17. T* ptr;
  18. };
  19.  
  20. class SGObject {
  21. public:
  22. bool equals(Some<SGObject> other) {
  23.  
  24. }
  25. };
  26.  
  27. class Subclass : public SGObject {
  28. public:
  29. };
  30. class OtherSubclass : public SGObject {
  31. public:
  32. };
  33.  
  34. int main() {
  35. Some<Subclass> one(new Subclass);
  36. Some<OtherSubclass> two(new OtherSubclass);
  37. return one->equals(two);
  38. // your code goes here
  39. return 0;
  40. }
Success #stdin #stdout 0s 16048KB
stdin
Standard input is empty
stdout
Standard output is empty