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

0

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??

c++

9/13/2021 3:09:36 PM

Eyob

3 Answers

New Answer

+2

"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.

+1

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

0

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