-1
stack<int*> 

vs

stack<int>

I am stuck in this kindly help if you know the Answer.

user4581301
  • 33,082
  • 7
  • 33
  • 54
  • Context would be nice.. so far it's typeid versus template's name, that's all – Swift - Friday Pie Nov 19 '20 at 06:30
  • 1
    One stores `int`s with stars. The other stores `int`s. Any [non-fraudulent C++ programming text](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) will tell you what the star means in the first few pages. – user4581301 Nov 19 '20 at 06:33
  • Do you know about pointers? And what `int*` means? It means nothing different when used as template parameter. – Lukas-T Nov 19 '20 at 06:34
  • Obviously you haven't learned yet about pointers. This is a good thing, but you have a whole world of pain ahead of you. – john Nov 19 '20 at 06:42

1 Answers1

3

int is a type. It is an integer type.

int* is a compound type. It is a pointer to an object of type int.

stack<T> is instantiation of a template named stack. The angle brackets denote the list of template arguments passed to the instantiation.

stack<int> is instantiation of the template for the type int.

stack<int*> is instantiation of the template for the type int*.

eerorika
  • 232,697
  • 12
  • 197
  • 326