Template member function | Sololearn: Learn to code for FREE!


Template member function

class A { public: template<class T> void foo(T c) { // Do stuff } } A* w; w->foo<NewStuff>(11); --- > not working w->template foo<NewStuff>(11); --- > not working any suggestion please??


9/13/2021 3:09:36 PM


3 Answers

New Answer


"w" is just a pointer which is supposed to point to an object of class A, but you never made it point to an object at first place. A *w = new A; Is what you are missing.


It would be much better to provide us with a minimum reproducible example of this error.


No, I did that I forget to include it in the question.... sorry!