Sunday, February 5, 2012

C++ Template Example

Posted by Jason On September - 29 - 2009

An Example/Tutorial on how to use C++ Templates
Templates are special functions to be used with more than one type of class or typename indentifier.

A Template Function looks usually like this format:
template<class MyType>
MyType GetMax(MyType a, MyType b)
{
return (a>b ? a: b);
}
with a call that looks like this:
GetMax<int>(x,y);

Templates can also be used with classes.  See the example:
C++ Template Example/Tutorial

Add A Comment

You must be logged in to post a comment.