fork download
  1. #include <iostream>
  2. #include <memory>
  3. using namespace std;
  4.  
  5. template<typename T>
  6. class BaseS
  7. {
  8. private:
  9. BaseS();
  10. BaseS(BaseS& bs);
  11. BaseS& operator=(const BaseS& bs);
  12. protected:
  13. enum e
  14. {
  15. one
  16. };
  17. BaseS(e _e)
  18. {
  19.  
  20. }
  21. public:
  22. template<typename... A>
  23. static T* print(A... a)
  24. {
  25. T * t = new T(one, a...);
  26. return t;
  27. }
  28. };
  29.  
  30. class AdevS : public BaseS<AdevS>
  31. {
  32. public:
  33. AdevS(e _e): BaseS(_e)
  34. {
  35.  
  36. }
  37.  
  38.  
  39. AdevS(int i): BaseS(one)
  40. {
  41.  
  42. }
  43.  
  44. AdevS(e _e, int i): BaseS(_e)
  45. {
  46.  
  47. }
  48.  
  49. };
  50.  
  51. int main() {
  52. // your code goes here
  53. std::weak_ptr<int> i;
  54. AdevS * a = AdevS::print(1);
  55. //AdevS b, c(1);
  56. return 0;
  57. }
Compilation error #stdin compilation error #stdout 0s 3424KB
stdin
Standard input is empty
compilation info
prog.cpp:22:19: warning: variadic templates only available with -std=c++11 or -std=gnu++11 [enabled by default]
  template<typename... A>
                   ^
prog.cpp:23:23: warning: variadic templates only available with -std=c++11 or -std=gnu++11 [enabled by default]
  static T* print(A... a)
                       ^
prog.cpp: In function ‘int main()’:
prog.cpp:53:2: error: ‘weak_ptr’ is not a member of ‘std’
  std::weak_ptr<int> i;
  ^
prog.cpp:53:16: error: expected primary-expression before ‘int’
  std::weak_ptr<int> i;
                ^
prog.cpp:53:16: error: expected ‘;’ before ‘int’
prog.cpp:54:10: warning: unused variable ‘a’ [-Wunused-variable]
  AdevS * a = AdevS::print(1);
          ^
stdout
Standard output is empty