[ad_1]
Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –
Buckys C++ Programming Tutorials – 59 – function Templates with Multiple Parameters
by
Tags:
Comments
33 responses to “Buckys C++ Programming Tutorials – 59 – function Templates with Multiple Parameters”
-
3:29 woah! Now I feel like a retard
-
instead of passing (y,x) cant we just change return type as SECOND instead of FIRST in the function
-
What if we pass 56.78 and 89 in reverse , would the answer type would be int then?
-
return (a<b?a:b); //Awesome code 😀
-
This guy is not a bad programmer.
-
Firstly : Thanks a lot Bucky!!! I love your tutorials!!
Secondly : lets say we have a function but we are not sure what it will return, First or Second? Is there a better way to code it so that it returns an integer or a float or a double automatically without rounding it off or something??. I hope I am clear about this. -
prety cool huh? oui oui
-
how to add through array
-
Brilliant.
-
thank
-
why is the return type FIRST? why not SECOND? please quick answer ><
-
Instead variable for this you can have variable for this.. 😛
-
//PassingbyReference & fuction templates
int x = 7, y = 43, z;
template <class bucky>
bucky addCrap(bucky *a, bucky *b){
*a = 20;
*b = 20;return 0;
}int main()
{
z = addCrap(&x,&y);cout << x << y << endl;
system("PAUSE");
return 0;
} -
#include "Indoor.h"
#include <iostream>using namespace std;
int main()
{
Indoor newobj(50,2.65);newobj.compare();
return 0;
}indoor class header
#ifndef INDOOR_H
#define INDOOR_Hclass Indoor
{
public:
Indoor(int c, double d);
//virtual ~Indoor();template < class ONE , class TWO > // Generic function TEMPLATES with two GENERIC PARAMETERS.
TWO compare( ONE a, TWO b) ; // generic function where "TWO" REPRESENTS "DOUBLE" and "ONE " represents "INT".int x; double y;
protected:
private:
};#endif // INDOOR
indoor.cpp
#include "Indoor.h"
#include <iostream>using namespace std;
Indoor::Indoor()
:x(c),y(d)
{
}TWO Indoor :: compare( ONE a, TWO b) // generic function where "TWO" REPRESENTS "DOUBLE" and "ONE " represents "INT".
{
return ( a<b? a:b );cout <<"THE SMALLEST VALUE IS: " << compare(x,y) <<endl;
}pls help me correct this error
error: no matching function for call to 'Indoor::compare()'
-
C:CODESGeneric function Templates using classesmain.cpp|1
got this error when i was trying to call" newobj.compare();" function in the intmain();
after creating Ageneric function template in separate classes ..and further used a member intialization1|error: no matching function for call to 'Indoor::compare()'|
-
What does (a<b?a:b) mean ?What's each character's role ?
-
Thanks!
-
Question: How can I make sure that I get the smaller value with precision, no matter the order of the parameter?
-
Am I the only 2001 ;-;
-
Thank you god lol
-
omg, you are a sooooooooo good tutor
-
that was cool stuff sir
-
Awesome! Thanks!
-
Hi guys,
why can't I write this way?template <class FIRST, class SECOND, class THIRD>
THIRD compare(FIRST a, SECOND b){
cout << (a<b?a:b) <<endl;
}int main()
{
compare(23,755.86);
return 0;
}Is there any way I can write a generic return type?
Thanks in advance. -
What if you don't know what type of data you will send into a function?
template generates all variation of function at compile time, how could it be ever known what must be generated, if you send arbitrary data from, say an array? -
3:18 Hello XDDDDDDD
-
thanks a lot for ur videos sir! is there a donation i can give you for saving my semester?
-
This channel is awesome
-
Thanks bucky you're awesome 🙂
-
Thanks Bucky for your amazing tutorials!!
Shortens time for just googling! -
6:14 …"yari yari yara"…
LOL -
so helpful thank u !
-
I've got the general idea of this tutorial except for the part where it only prints out the numbers after the decimal points. Why does the program only print them if the double is called first?
Leave a Reply