Buckys C++ Programming Tutorials – 59 – function Templates with Multiple Parameters

[ad_1]
Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –


Posted

in

by

Tags:

Comments

33 responses to “Buckys C++ Programming Tutorials – 59 – function Templates with Multiple Parameters”

  1. Poh Ti Avatar

    3:29 woah! Now I feel like a retard

  2. EaGle Network Avatar

    instead of passing (y,x) cant we just change return type as SECOND instead of FIRST in the function

  3. Amit Gaurav Avatar

    What if we pass 56.78 and 89 in reverse , would the answer type would be int then?

  4. MaximalGamingNL Avatar

    return (a<b?a:b); //Awesome code 😀

  5. Yu Zhao Avatar

    This guy is not a bad programmer.

  6. Saqib Dhuka Avatar

    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.

  7. Boss6201 Avatar

    prety cool huh? oui oui

  8. Zillay Nain Zukhraf Avatar

    how to add through array

  9. meriam zayani Avatar

    why is the return type FIRST? why not SECOND? please quick answer ><

  10. rashed azad Avatar

    Instead variable for this you can have variable for this.. 😛

  11. kenneth 92 Avatar

    //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;
    }

  12. Albert Agyemang Avatar

    #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_H

    class 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()'

  13. Albert Agyemang Avatar

    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 intialization

    1|error: no matching function for call to 'Indoor::compare()'|

  14. VeldroN Avatar

    What does (a<b?a:b) mean ?What's each character's role ?

  15. Yousuf Azad Sami Avatar

    Question: How can I make sure that I get the smaller value with precision, no matter the order of the parameter?

  16. jonathan purcell Avatar

    Am I the only 2001 ;-;

  17. Avarus Surava Avatar

    Thank you god lol

  18. ZhiFeng Chen Avatar

    omg, you are a sooooooooo good tutor

  19. dulam shiva Avatar

    that was cool stuff sir

  20. Saadiya Avatar

    Awesome! Thanks!

  21. krishna teja Avatar

    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.

  22. rospotreb pozor Avatar

    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?

  23. Ownage Zizou Avatar

    thanks a lot for ur videos sir! is there a donation i can give you for saving my semester?

  24. Leon Duan Avatar

    This channel is awesome

  25. Meemzz15 Avatar

    Thanks bucky you're awesome 🙂

  26. hyeokhyen Kwon Avatar

    Thanks Bucky for your amazing tutorials!!
    Shortens time for just googling!

  27. Bl00d_Lu$t UPSB Avatar

    6:14 …"yari yari yara"…
    LOL

  28. Ons Dlaili Avatar

    so helpful thank u !

  29. The_Cullen_ Avatar

    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

Your email address will not be published. Required fields are marked *