205. Write a program to perform above operation by using template data type?

#include<iostream.h> #include<conio.h> template <class T> class demo { public:                 demo(T ch)                                 {                                 cout<<"Value = "<<ch<<endl;                                 } }; void main() {                 clrscr();                 demo <char> x('A');                 demo <int> y(10);                 demo <double> z(15.13);                 getch(); }

Advertisements

204. Write a program to work with different data type by without using template keyword?

#include<iostream.h> #include<conio.h> class demo { public:                 demo(char ch)                                 {                                 cout<<"Character = "<<ch<<endl;                                }                 demo(int i)                                 {                                 cout<<"Integer = "<<i<<endl;                                 }                 demo(double d)                                 {                                 cout<<"Double = "<<d<<endl;                                 } }; void main() {                 clrscr();                 demo x('A');                 demo y(10);                 demo z(15.13);                ... Continue Reading →

203. Write a program to create an object outside the function?

#include<iostream.h> #include<conio.h> class number {                 int a; public:                 void get()                                 {                                 cout<<"Enter A Number : ";                                 cin>>a;                                 }                 void display()                                 {                                 cout<<"The Number Is : "<<a<<endl;                                 } }; number m,n; void main() {                 clrscr();                 number n;                 n.get(); //Local Object                 m.get();                ... Continue Reading →

202. Write a program to show the use of this pointer?

#include<iostream.h> #include<conio.h> class number {                 int a; public:                 void get()                                 {                                 cout<<"Enter A Number : ";                                 cin>>a;                                 }                 number check(number num)                                 {                                 if(num.a>a)                                                 {                                                 return num;                                                 }                                 else                                                 {                                                 return *this;                                                 }                                 }                 void display()                                 {... Continue Reading →

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: