Why type is not required for smart pointer of type shared pointer? | Sololearn: Learn to code for FREE!
+ 1

Why type is not required for smart pointer of type shared pointer?

Hi AFIK, shared_ptr is a template class. To create object of that class , we need to specify type. Refer attached code and observe below line into print function: shared_ptr temp = head; why type node is not required like shared_ptr<node> ? I was expecting compiler error without type but it works fine.. How this is possible? https://code.sololearn.com/crYV1fiFiNPr/?ref=app

24th Jul 2021, 3:33 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
1 Resposta
24th Jul 2021, 5:48 PM
Dennis
Dennis - avatar