Buckys C++ Programming Tutorials – 60 – class Templates

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


Posted

in

by

Tags:

Comments

36 responses to “Buckys C++ Programming Tutorials – 60 – class Templates”

  1. bardown32 Avatar

    Thanks Bucky Roberts.

  2. Hà Chí Hào Avatar

    Can we write the bigger function inside the class ?

  3. ImaginaryHuman072889 Avatar

    when you choose the data type that represents T in your template, can it be another class?

  4. Charles Li Avatar

    This is great, thanks.

  5. sarmad fayyaz Avatar

    thank u sho much sir i really appreciate u . i salute u

  6. mulia sf Avatar

    thanks you very much. this tutorials helping me so much. hahahahahahah

  7. Nitesh Agarwal Avatar

    Isnt the whole point of template was to use generic int,double etc types. Now with this <int> we have to pass integers only. Cant we pass mixed type arguments like the previous video?

  8. Tal K Avatar

    the problem that you dont show nor explain this should be .hpp only calss and why and also that you dont have to implement the bodu function outside the class cause you must do it in the same class anyway in generic classes so you also showing the hard way to do it

  9. Boss6201 Avatar

    Thanks a lot Bucky you can't imagine how all your videos help me a lot.

  10. PmrNut Avatar

    @1:54 – You should make use of the member initialization list, since your template could very well allow for data types that are not "Plain Old Data" and they are not static. It's more intuitive and is faster for user defined types.

  11. srihari sridhar Avatar

    Why can't I define the function within the class?

  12. Salty Snake Avatar

    thank you so much!

  13. Man Hattan Avatar

    I never saw a "?"-Operator

  14. Early Morning Avatar

    You are so freindly bucky….thankx

  15. Alex Tan Avatar

    Why the function T Bigger ( ) can without a "friend" to use the variables in class Bucky?

  16. Kurai .CSGO Avatar

    cant "forget about it" when i gotta do a final exam on it

  17. Илья Боюр Avatar

    Explain plz what category are "first" and "second" variables of type T in your template class?
    Usually, in all last classes you aways explicitly point on which type of category of function objects you are dealing with – private, public or protected. So what is first, second?
    Since you didn't specify it here, I am confused.)

  18. Jose Gonzalez Avatar

    I still don't see the difference from using templates and using the type, "auto".

  19. Karthikeyan K Avatar

    the line "Bucky <int> doesn't make any sense coz template is used to handle any datatypr right???

  20. Hiro Nakae Avatar

    You sound like NightBlu3 haha

  21. Jonathan Copeland Avatar

    You've added so much value! Thank you!

  22. yousha arif Avatar

    #include<iostream.h>
    #include<conio.h>
    #include<stdio.h>
    #include<stdlib.h>
    struct node
    {
    int data;
    node *left;
    node right; ///what is this ??!! Please tell me do you have tutorial for these ?? *_
    };

    node *tree=NULL;
    node *insert(node *tree,int ele);

  23. CobraL0rd Avatar

    This is almost more trouble than it's worth.

  24. Aaron Derbyshire Avatar

    So to date I have been able to follow your tutorials quite well and see the materials application to a real system. However, with this tutorial I am at a loss? 

    We've defined our own class to allow for any data type to enter the function,  an attribute I would have thought was used because we don't know the data type in advance? Yet in using the function we have to specify the data type? Not only this but the functions return type is also defined by the first pass in argument?

    This to me seems irrelevant unless we define a third generic data type to be used as the return type of the function? 

    I guess what I am asking is, firstly, will using a third generic data type allow us to obtain the full return value of the larger number (say we compared 45 and 62.54?). Secondly, is there away to use the function without having to specify the datatype of the input parameters during the function call?

    Any help would be appreciated.

  25. Christopher Anemopoulos Avatar

    couldn't we initialize the variables in the constructor?

  26. William G. Lewis Avatar

    Can anyone tell me what compiler software being used? I am new to learning C++ and this seems like a very handy tool.

  27. Kulamani Sethi Avatar

    If one parameter is int and other is double at line:21 then?
    like Bucky <int> bo(258, 105.5); Should i write like <int , double> ?

  28. Академия Программиста Avatar

    Would be nice to see an explanation in several examples of a practical usage of T in C++ at class level.

  29. Vibhore Bhardwaj Avatar

    I have a question.?

    what is <class T> : generic class or generic data type ..?
    because bucky use the term interchangeably.!

  30. Diego de Paula Avatar

    Shouldn't the line " T first, second; " be bellow a access specifier as in:
    Class Bucky{
    Private:
    T first, second;
    Public:
    Bucky()etc…

  31. sabri ömür yıldırmaz Avatar

    Hello!

    I have understand how to create function and class templates. Also I have understand why we can use function templates (to avoid function overloading and making our job easier). But still couldn't figure out the concept behind the "Class Templates". Why are we using them? Can someone please explain me?

    Thank you very much!

  32. Nathan James Avatar

    6:27 – using 69 and 0x69 🙂

  33. Smael64 Avatar

    But we just can't go ahead and add the body that would be too easy and this is C++.

  34. steve122288 Avatar

    are angle brackets only used for templates? it seems like there is alot left unexplained even if this is the case. Like he never says why you have to type in class; after a quick search it appears there is things i never heard of that you can pass into the angle brackets after template.. like this template <typename T, size_t N> . Then it is followed to make a structure lol. I think typename and size_t are already made objects in the guys code tho.

  35. steve122288 Avatar

    he says he doesnt know why you have to write template twice, but he doesn't say why you have to write void and int and such twice, so i imagine the same rules apply. In order for class T to work, the template keyword must be used, since otherwise, T is not a valid data type. The template keyword seems to only work for one data type under it, which is why it can only be used for the class data type below it, then it must be called again to be used for the function definition.

Leave a Reply

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