#include<iostream.h>
#include<conio.h>
template<class T>
class numbers
{
private:
T x1, x2, sum;
public:
void in();
void out();
}; // End of class templates
template<class T>
void numbers<T> :: in()
{
cout<<"Enter two numbers " <<endl;
cin>>x1>>x2;
}
template<class T>
void numbers<T> :: out()
{
T total;
sum = x1 + x2;
cout <<x1<<" + " <<x2<<" = " <<sum;
cout<<endl;
}
int main()
{
clrscr();
numbers <int> iob;
numbers <float> fob;
cout<<"Integer case ...... ";
cout<<endl;
iob.in();
iob.out();
cout<<endl;
cout<<"Floating-point case ......";
cout<<endl;
fob.in();
fob.out();
getch();
return 0;
}
SiteMap
|
Link Us
...Language...
English
French
German
Hindi
Italian
Russian
Japanese
Chinese
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 definition and declaration of a class template for accepting two numbers and finding their sum.
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