fork download
  1. class Foo1
  2. {
  3. public:
  4. const int* bar;
  5.  
  6. Foo1()
  7. {
  8. bar = new int[2] {1, 2};
  9. }
  10. };
  11.  
  12. template<int A, int B>
  13. class Foo2
  14. {
  15. public:
  16. const int* bar;
  17.  
  18. Foo2()
  19. {
  20. bar = new int[2] {A, B};
  21. }
  22. };
  23.  
  24. int main() {
  25. Foo1 a;
  26. Foo2<1,2> b;
  27. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In constructor 'Foo2<A, B>::Foo2()':
prog.cpp:20:35: error: ISO C++ forbids initialization in array new
stdout

Standard output is empty