Template, as the name suggested is a standard or generic way/form we could use for creating different output. For an example, you would ask for a report template from your senior so that you more or less know how what is expected from you.
One of the benefits of programming through a template, it reduces the effort to recode the same function/class but pass in a different variable type. Our good friend the STL Algorithms is the best example of programming template. Imagine the sort() function need to be rewrite again and again and again for each type of variable...............
I strongly do not advocate of getting report from other people and change it to your name. That is not template nor referencing. It is called plagiarism.
A function template or class template, beside used with primary variable, eg int, char, double. It can be used with data structures too. As usual, it is possible to pass in more then 1 parameter of the same or different variable type to the function template or class template.
reference the code below. NOTE: The Code is NOT COMPLETE you need to fix it before you could use it.
Q1. What does both of the function trying to do??? Is there a way to generalize it without repeating the "same" code?
Q2. Populate the given code with a template function that will double each number stored as elements in the data structure. Is it possible to double a char or a string stored in the data structure??
//===CHALLENGE==> HEROES ONLY=====//
Q3. Write a template function reverselist() that could take in a list display the content of the list and store the contents of the list on to a stack and later display the content of the stack.
Q4. Is there a more efficient way to create a test for a palindrome????
Monday, November 8, 2010
Subscribe to:
Post Comments (Atom)
26 comments:
http://snipt.net/sgxbuster/rect-template
http://snipt.net/puteraafiq/template-15/
http://snipt.net/BernardChew/using-template
http://snipt.net/RuiWei/template-16
http://snipt.net/dannygsy/danny-2b05-1
http://snipt.net/dannygsy/danny-2b05-1
http://snipt.net/embed/abf4caf613e737a1edde7f4c1e2a2ab2
http://snipt.net/edwinraja/using-templates-to-calculate-area-and-volume
http://snipt.net/crazygameazz/template-17
@guys,
keep the code coming in~~!!~~
http://snipt.net/alvinthen/9-nov-2010?key=6d494170494528ed64be30931ce0356b
http://snipt.net/jellybanana/week-4-functions-practice
http://snipt.net/asdsieg/function
http://snipt.net/UJuzGtJacked/areavoltemplate?key=a99ceebd7fa618dc79a2fe4eb7c805f0
http://snipt.net/bigshow/week-4
http://snipt.net/alvinthen/9-nov-2010-template?key=97d11e9b8917ea0b2e9533bc93e60079
http://snipt.net/UJuzGtJacked/areavoltemplatemodified/?key=93d4a5c6725f013d3c9e5584f3c3a625
http://snipt.net/Wizardgenesis/template-example/?key=f583ef2afaf76ea59e1a8c349aa2f550
http://snipt.net/jellybanana/week-4-template-functions
http://snipt.net/asdsieg/template-18
http://snipt.net/Stish/templates-2
http://snipt.net/bigshow/week42
http://snipt.net/sa198/qi-haodcpe2b03-3/?key=9307d4749ff6004a5ad37015b25a1dbf
http://snipt.net/sa198/qi-haodcpe2b03-4/?key=ac0dc38fd5b08ed2dac7834cd39d44d9
http://snipt.net/xiaofei/use-tem-to-cal-a-and-v
http://snipt.net/hengnee/sorry-for-sending-in-so-late
http://snipt.net/J0k3r/tag/template
Post a Comment