fork download
  1. template<int SIZE>
  2. class FixedString
  3. {
  4. public:
  5. operator const char*();
  6. void operator =(const char*);
  7.  
  8. void operator =(const FixedString&);
  9.  
  10. // Disallow
  11. private:
  12. template<int OTHERSIZE>
  13. void operator=(const FixedString<OTHERSIZE>&);
  14. };
  15.  
  16. int main()
  17. {
  18. FixedString<10> buf1;
  19. FixedString<20> buf2;
  20.  
  21. buf2 = buf1; // NO ERROR!!
  22. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:13:10: error: ‘void FixedString<SIZE>::operator=(const FixedString<OTHERSIZE>&) [with int OTHERSIZE = 10; int SIZE = 20]’ is private
prog.cpp:21:12: error: within this context
stdout
Standard output is empty