+ 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
1 Resposta
+ 4
Short answer: C++17.
Longer answer:
https://en.cppreference.com/w/cpp/language/class_template_argument_deduction