Can I have a template class pointer as a parameter when declaring an object of that class in C ++?
Here is the code version of the question:
template <class T>
class Foo
{
//Stuff
}
Foo<Foo*> object;
Compiling this gives me:
"template argument 1 is an invalid error."
My question is:
- if it is possible to perform the above action, and if so, how and why does this method work?
- If this is not possible, I assume it is due to the presence of a circular reference within the template parameter itself (e.g.
Foo<Foo<Foo<.....>>>
, but please let me know the correct reason if I am wrong in my thoughts.
Also I tried forward declaration Foo
and it didn't work.
+3
source to share
1 answer