#include<iostream.h>
#include<conio.h>
template<class T>
class Array
{
private:
T* arr;
int size;
static int count;
public:
Array (int size=5);
~Array () ; // destructor
{
delete[] arr;
}
void readArray (void);
void display (void);
static int total_no_of_array->[]
{
return count;
}
}; / / End of class template
template <class T>
Array <T> :: Array (int sz)
{
size = sz;
arr = new T[size];
for (int i=0; i<size; i++)
{
arr[i] = (T)0;
}
}
template <class T>
int Array<T> :: count = 0;
// static data members initialization
template<class T>
void Array<T> :: readArray(void)
{
for(int i=0; i<size; i++)
{
cin>>arr[i];
}
count++;
}
template <class T>
void Array<T>::read Array(void)
{
for(int=0; i<size; i++)
{
cin>>arr[i];
}
cout++;
}
template<class T>
void Array<T> :: display(void)
{
for (int i = 0; i<size; i++)
{
cout<<arr[i] <<endl;
}
cout <<endl;
}
int main()
{
Array<int>IArr(5);
Array<double>Darr(5);
clrscr();
cout<<endl;
cout<< “Enter integer elements “;
cout<<endl;
IArr.readArray();
cout<<”Integer array elements are “;
cout<<endl;
IArr.display();
cout<<”Enter double-precision numbers”;
cout<<endl;
Darr.readArray();
cout<<”Double-precision array elements are”;
cout<<endl;
Darr.display();
cout<<”Total number of integer array=”<<Array<int> :: total_no_of_array();
cout<<endl;
cout<<”Total number of double array=”<<Array <double> :: total_no_of_array();
cout<<endl;
getch();
return 0;
} // End of main
Home       |      About Us       |     Portfolio       |      Services       |       Career        |    Contact Us       |      Industrial Training        |      Achievement 
Corporate Services
  Web Design and development
  Web Promotion (SEO)
  Multimedia/CD Presentation
  Software development

  E.Commerce

Training@balujalabs

  Software Courses
  Hardware Courses
  Networking.Courses
  Mobile Repairing Courses
  UGC Degrees
Student Corner
 Programming & Projects
 Placement Papers
 Project Ideas
 Synopsis Ideas

  Franchise Section

 Administrator
Franchise Inquiry
 
 

This program illustrates the static data members of class templates.

 

 

 

 

 

 

 

 

 

                                                                                                                                          

1 This program illustrates the definition and declaration of a class template for accepting two numbers and finding their sum.
2 This process is to define and declare a class template for stack. A stack is a data structure in which all insertions and deletions are made at the same end called top insertions are called push operations while deletions are referred to as pop operations.
3 This program is to create a template class Queue, with add and delete member functions. And, using this class template, a queue of integers and doubles is implemented.
4 This program illustrates the static data members of class templates.

 

     
Home       |      About Us       |     Portfolio       |      Services       |       Career        |    Contact Us       |      Industrial Training        |      Achievement