Networking, Programming and Graphics Tutorials

Class templates - C++ [1/1]

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

Generic classes can be created using a template with an anonymous type.

General format 
template 
<class T
class 
classname {
//..........
// class member specification 
// with anonymous type T 
// wherever appropriate 
//.......
};


classname<typeobjectname(arglist);
A class created from a class template is called a template class. The general format for defining an object of a template class is shown above. The process of creating a specific class from a class template is called instantiation. The compiler performs error checking after the instantiation of a class. So it is better to debug an ordinary class before converting it into a template.

The figure illustrates the concept behind class template.

Class templates - C++
Rate this tutorial:                    
Networking, Programming and Graphics Tutorials - Class 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++  class C++  C++ class within a class  c++ arrays within a class  arrays within a class  array within a class C++  "arrays in class" c++  class abstraction "c++"  class hierarchy c++ example  what is the sream class in c++  c++ stream class  class type C++  stream class in c++  "arrays within a class"  webcam class for C++  nurbs class c++  "class declaration in c++"  stream class in c++