Function Template C++ | Generic | OOPs in C++ | Lec-38 | Bhanu Priya

preview_player
Показать описание
Generic -Template function with example in c++
for more related videos
Рекомендации по теме
Комментарии
Автор

Tq mam this video is very useful for me...

vanim
Автор

Great explanation...thanks a lot. Great video

AeroDZ
Автор

Thanks mam to giving us such a wonderful lecture thanks a lot...

shashankshekhar
Автор

nice explainaton by you mam you should create more videos in many other topics

pratiksrivastava
Автор

Very good explanation thank u so much mam🙂

patil
Автор

i like your lecture but one ting missing is that you can't do pricticle work

MuhammadAbbas-bfwo
Автор

Will explain about command line argument in cpp

manjeeshmanoharan
Автор

/* Multiple swap function
#include<iostream>
using namespace std;

void swap (char &x, char &y){
char t;
t=x; x=y; y=t;
};
void swap(int &x, int &y){
int t;
t=x; x=y; y=t;

};
void swap(float &x, float &y){
float t;
t=x; x=y; y=t;

};
int main()
{
char ch1, ch2;
cout<<"\n enter values:";
cin>>ch1>>ch2;
swap(ch1, ch2);
cout<<"\n after swap ch1 :"<<ch1<<"\tch2 :"<<ch2<<endl;
int a, b;
cout<<"\n enter values:";
cin>>a>>b;
swap(a, b);
cout<<"\n after swap a :"<<a<<"\tb :"<<b<<endl;
float c, d;
cout<<"\n enter values:";
cin>>c>>d;
swap(c, d);
cout<<"in after swap c :"<<c<<"\td :"<<d<<endl;





return 0;
} */


//



#include<iostream>
using namespace std;

template<class T>
void mySwap(T &x, T &y){
T t;
t=x; x=y; y=t;
}
int main()
{
char ch1, ch2;
cout<<"Enter the character values :"<<endl;
cin>>ch1>>ch2;
mySwap(ch1, ch2);
cout<<"After swapping the character = \nch1:"<<ch1<<" "<<"Ch2:"<<ch2<<endl;

int a, b;
cout<<"Enter the intergers values:"<<endl;
cin>>a>>b;
mySwap(a, b);
cout<<"After swapping integers = \na:"<<a<<" "<<"b:"<<b<<endl;

float p, q;
cout<<"Enter the floats values:"<<endl;
cin>>p>>q;
mySwap(p, q);
cout<<"After swapping the floats = \np:"<<p<<" "<<"q:"<<q<<endl;

return 0;
}

RahiqAlMakhtum
Автор

very helpful but don't need advertisement.

surajk.c.
Автор

In the generic function we have to write T before function name

sumanghosh
Автор

Please speak Hindi also. It's easy for a indian student.

glassinocean
Автор

English m smjhna hota to books m hi smjhlete hum 🤦..

wasilansari
Автор

Urdu me smjha den to acha samjh ae ga hamen

muhammadosamanusrat
Автор

Kuch smj ni aya hindi m bhi explain kr deti ak bar😤😤

Mishu