Ask your own question, for FREE!
Computer Science 15 Online
OpenStudy (anonymous):

hello guys :D I don't understand what are templates in C++ used for?

OpenStudy (anonymous):

templates are basically used to reduce code repetition. they allow you to have functions and classes that operate around different types, while still using static typing. for instance, what if you want a list of integers and a linked list of strings? instead of writing two separate classes like IntList and StringList, you just use std::list<int> and std::list<std::string> or something like that.

OpenStudy (anonymous):

in practice they have a lot of other uses and can get incredibly complicated, but thats the short version

OpenStudy (anonymous):

Great; I was wondering what they were used for too :-P

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!