fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Test {
  5. public:
  6. void Start() {
  7. cout << "Start" << endl;
  8. }
  9. void Stop() {
  10. cout << "Stop" << endl;
  11. }
  12. };
  13.  
  14. template<typename T = Test>
  15. class Location : public T {
  16. public:
  17. Location() {
  18. T::Start();
  19. }
  20. ~Location() {
  21. T::Stop();
  22. }
  23. };
  24.  
  25. template<typename T, typename T2>
  26. class Location<T2> : public T {
  27. public:
  28. Location() {
  29. T::Start();
  30. }
  31. ~Location() {
  32. T::Stop();
  33. }
  34. };
  35.  
  36. int main() {
  37. Location<Test, int> obj;
  38. // your code goes here
  39. return 0;
  40. }
Compilation error #stdin compilation error #stdout 0s 4396KB
stdin
Standard input is empty
compilation info
prog.cpp:26:7: error: template parameters not deducible in partial specialization:
 class Location<T2> : public T {
       ^~~~~~~~~~~~
prog.cpp:26:7: note:         ‘T’
prog.cpp: In function ‘int main()’:
prog.cpp:37:20: error: wrong number of template arguments (2, should be at least 0)
  Location<Test, int> obj;
                    ^
prog.cpp:15:7: note: provided for ‘template<class T> class Location’
 class Location : public T {
       ^~~~~~~~
stdout
Standard output is empty