Stack Implementation Using Templates/

I am getting what wrong with my code It is giving compilation error. What I want to do is to implement a stack using templates.

Hello @sk14452,

You have to consider following things to correct your code.

  1. You are deleting head instead of temp. This will delete the element next to top in the satck.

  2. You have to declare separate templates for each class.

3.Each time you instantiate/ declare object of any template class, you have to specify the type of the object.

I have modified your code.
Now, it’s working perfectly.
You can check it here.

Hope, this would help.
Give a like, if you are satisfied.

1 Like

Thank you so much Man!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.