fork download
  1. #include <memory>
  2.  
  3. template<typename T>
  4. class GetProperty
  5. {
  6. private:
  7. T (*get)();
  8. public:
  9. GetProperty(T (*get)())
  10. {
  11. this->get = get;
  12. }
  13. operator T()
  14. {
  15. return get();
  16. }
  17. template<typename S, typename T>
  18. GetProperty<S> operator=(GetProperty<T> fool)
  19. {
  20. throw 0;
  21. }
  22. };
  23. template<typename T>
  24. class Vector
  25. {
  26. private:
  27. struct LinkItem
  28. {
  29. public:
  30. T* Item;
  31. LinkItem* Next;
  32. GetProperty<int> Length (&getLength);
  33. LinkItem(T* Item = NULL, int length = 1, LinkItem* Next = NULL)
  34. {
  35. this->Item = Item;
  36. this->length = length;
  37. this->Next = Next;
  38. }
  39. LinkItem& operator =(LinkItem rhs)
  40. {
  41. this->Item = rhs.Item;
  42. this->length = rhs.length;
  43. this->Next = rhs.Next;
  44. return *this;
  45. }
  46. private:
  47. int length;
  48. int getLength()
  49. {
  50. return length;
  51. }
  52. };
  53. LinkItem* current;
  54. ...
  55. };
  56.  
  57. int main() {
  58. Vector<char> a;
  59. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:17:30: error: declaration of 'class T'
prog.cpp:3:10: error:  shadows template parm 'class T'
prog.cpp:32:58: error: expected identifier before '&' token
prog.cpp:54:5: error: expected unqualified-id before '...' token
stdout
Standard output is empty