Josh McFarlane
darsant at gmail.com
Sat Jan 21 15:49:47 CST 2006
On 1/21/06, John Colby <jwcolby at colbyconsulting.com> wrote: > I understand the concept of placing a bunch of code/formatting etc in a > file, calling it a template, and then opening that to "start" a new object > of that type. But is the template write protected, i.e. if I open one and > attempt to save it it will prompt for a file name or something? How are > they used by us programmers? Templating in that fashion is more something on the word / excel side, I'm not sure how much VBA uses templates, but let me explain to you how the C++ side of templates work: Say you want a simple function that compares two objects of the same type. You could go through and define this two ways, IE you could do: CompareInt CompareFloat CompareDouble etc Or instead, if you wanted to think about it as a template, you make one function, and just have it compare type T (user defined when they call the function) This way, if you call the function on ints, it compares types of ints, if you call it with doubles, it compares types of doubles. The function serves as a template for any type of variable you call on it, as long as A > B means something for that type. -- Josh McFarlane "Peace cannot be kept by force. It can only be achieved by understanding." -Albert Einstein