Networking, Programming and Graphics Tutorials

Templates - C++ [1/1]

Type:
Templates - C++
Level: Expert Networking, Programming and Graphics Tutorials Networking, Programming and Graphics Tutorials Networking, Programming and Graphics Tutorials 
Templates - C++
Date: 2006-Dec-12
Templates - C++
Visited: 1097 times
Templates - C++
Rating: Templates - C++
Templates - C++
Author: Alex Plumpton

Templates enable to define and create generic classes or function. The template can be considered as a kind of macro. When an object of a specific type is defined for actual use, template definition for that class is substituted with the required datatype. There are two types of templates. They are function template and class template.

Example
Write a 
function that returns square value of a numberThe type of the number can be intlongfloat.


int sqrt(int n)
{
return (
nn);
}
long sqrt(long n)
{
return (
n*n);
}
float sqrt(float n)
{
return(
n*n);
}

The figure illustrates the concept behind the template functions.

Templates - C++
Rate this tutorial:                    
Networking, Programming and Graphics Tutorials - Templates - C++ [1/1] - Networking, Programming and Graphics Tutorials

Need a specific tutorial? Do not hesitate and submit a request!
Related Tags: templates - C++  templates C++ ""  conflicting templates C++  making 3D anything  instant messangers  how to burn iso with nero  Online Home Network Diagnostics  C++ encapsulation  yahoo messangers  php.info file  pop proxy settings outlook  tracert tutorial  trillian port number  how to build an info.php file  xp network diagnostic  do while in c++  for loop in c++  SMTP Commands test  fill arrays in php  email troubleshooting