Class Templates in C++ with Program Example | C++ Programmming

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 ม.ค. 2025

ความคิดเห็น • 134

  • @SimpleSnippets
    @SimpleSnippets  5 ปีที่แล้ว +18

    Hey Guys, if you want more such tech educational videos on this channel then please support me by subscribing to this channel & also share it with your friends as it helps me create more content just for you ✌

    • @rajveerbhai7624
      @rajveerbhai7624 ปีที่แล้ว +3

      Wow I just discovered this channel. And I really like your way of teaching. It's helps me so much.
      Thank you

    • @SimpleSnippets
      @SimpleSnippets  ปีที่แล้ว +1

      Very happy to know this Rajveer! Keep growing and learning 😊

  • @irshadwahab
    @irshadwahab 4 ปีที่แล้ว +46

    Your style is excellent! Simple examples and to the point, easy to understand and the 2x speed means, not boring!! You are a good teacher! Great work!!

  • @adisingh9341
    @adisingh9341 3 ปีที่แล้ว +29

    Bro no kidding , I'm absolutely in complete awe to see you explained everything that there is to templates in such a short vid .

    • @dereksisco4790
      @dereksisco4790 3 ปีที่แล้ว +7

      Yeah but you have to play the video at 50% to catch half of what he's saying in some parts.

    • @SimpleSnippets
      @SimpleSnippets  3 ปีที่แล้ว +10

      Sorry for the speed Derek. I've reduced my speed in recent videos by taking all your constructive feedback. It has helped me & our channel improve 👍😊

    • @sciencesosimple2418
      @sciencesosimple2418 3 ปีที่แล้ว +3

      Yes u r right

    • @SK-wr3ww
      @SK-wr3ww 3 ปีที่แล้ว +2

      @@dereksisco4790 I watch all of his videos at 1.5x speed lol

    • @devrao3537
      @devrao3537 3 ปีที่แล้ว +3

      @@dereksisco4790 I watch his vids at 2x LMAO... Prolly cuz I'm used to his accent

  • @saga1658
    @saga1658 4 ปีที่แล้ว +6

    the way you represent and teach is too good

  • @michaelhernandez2075
    @michaelhernandez2075 3 ปีที่แล้ว +1

    Holy fucking hell thank you for the clear and concise tutorial. I have been watching shit from like 10 years ago that wasn't helping me what so ever. thank you.

  • @haripriyap3701
    @haripriyap3701 6 ปีที่แล้ว +6

    The channel which i loved😍😍no need of any other class..

    • @SimpleSnippets
      @SimpleSnippets  6 ปีที่แล้ว +1

      Thank you so much buddy 😇 I'm so happy that you like this video and this channel. Please do share the videos and channel with your friends and contacts. That will be the best help you can give our channel 😇 ✌️

  • @44mod
    @44mod 5 ปีที่แล้ว +12

    You do a great job I can follow your videos easily. Thank you!

    • @SimpleSnippets
      @SimpleSnippets  5 ปีที่แล้ว +2

      Thank you so much bro 😊 means a lot to me. I would request you to please share the video with your friends too ✌️

  • @sauravdutta99
    @sauravdutta99 4 ปีที่แล้ว +6

    template is used for-1.memory space 2.programming language 3.variable value 4.variable address

  • @Satvikshukla0007
    @Satvikshukla0007 2 ปีที่แล้ว

    was struggling to get this concept, you made it really easy, thanks.

  • @nirajmalik0910
    @nirajmalik0910 ปีที่แล้ว +1

    Stacks is LIFO
    That means
    Last In First Out (LIFO)

  • @imankhalid3191
    @imankhalid3191 3 ปีที่แล้ว

    You're a lifesaver for sure.

  • @yashdongre1752
    @yashdongre1752 3 ปีที่แล้ว

    Nicely Explained then all other TH-camrs Thanks:)

  • @saumyayadav8596
    @saumyayadav8596 6 ปีที่แล้ว +2

    Your videos are the best . Please keep uploading them.

    • @SimpleSnippets
      @SimpleSnippets  6 ปีที่แล้ว

      Thank you so much Saumya 😊 happy to hear this from you. Surely will keep uploading more content. ✌️
      I would request you to please share the video with your friends too 😊✌️

  • @deepikaarora8125
    @deepikaarora8125 3 ปีที่แล้ว +1

    you are a great teacher i subscribed you in single video too good...thank you so much

  • @i_write7500
    @i_write7500 ปีที่แล้ว +2

    How did you make it so Simple❤️
    Its really helpful!
    Thank you very much🌟

  • @shashimohansingh140
    @shashimohansingh140 3 ปีที่แล้ว

    Thanks sir, through your explaination I understand it very easily.

  • @sethji3950
    @sethji3950 5 ปีที่แล้ว +2

    Conceptual videos, I liked it bro 😎...

    • @SimpleSnippets
      @SimpleSnippets  5 ปีที่แล้ว

      Thank you so much buddy, Please do share this video with your friends too. Thats the biggest help and support 🙂

  • @insanegamer5275
    @insanegamer5275 2 ปีที่แล้ว

    best of the best

  • @AsadKhan-yx5gg
    @AsadKhan-yx5gg 3 ปีที่แล้ว +1

    Thanks you are good teacher 👍👍

  • @jamesnash9675
    @jamesnash9675 2 ปีที่แล้ว

    you are the best.........masum

  • @devrao3537
    @devrao3537 3 ปีที่แล้ว

    Bhai tu sahi mein bahgwan ho!

  • @iliyafathma8325
    @iliyafathma8325 2 ปีที่แล้ว

    Thank you so much for these videos it is really helpful and most importantly your explanation is simple and to the point which makes it easier to understand 😊😁

  • @jamesnash9675
    @jamesnash9675 2 ปีที่แล้ว

    you are the best................masum

  • @harounlouati6602
    @harounlouati6602 ปีที่แล้ว

    Well explained, thank you so much.

  • @siddharthdhingra3627
    @siddharthdhingra3627 2 ปีที่แล้ว

    Very goog video! Keep it up!!!

  • @abhimanyualtekar7060
    @abhimanyualtekar7060 3 ปีที่แล้ว

    I am trying to write function IIF(Condition, TruePart, FalsePart) like VB, Clipper/ FoxPro ,
    TruePart and FalsePart can be float* (array) or just float, also TruPart & FalsePart can be Null.
    When all arguments/parameters are scalars (numbers) then resulting value is also a scalar (number). When any of arguments is an float array (array pointer) then function needs to return an array pointer. This is the most important part.
    The Condition is Expression Like-
    1) ArrayA > ArrayB 2) floatX > floatY ?, ArrayX < 10 .
    .
    Comparison of scalar type parameters is very with (x == y ? a : b)
    But for float * (array pointer) each element of array is to be checked for TruePartArray & FalsePartArray
    These are some examples
    IIF(arrayA > ArrayB, ArrayX , ArrayZ)
    IIF (ArrayA > 10, ArrayX, Null) // resulting array will be added with all Null(s) as FalsePart
    IIF(ArrayX == FloatA, ArrayA, ArrayB)
    IIF( FlatA >= FloaB, ArrayX, Array)
    Condition is an expression so that is to be handled separately for Operator parsing and operator can be passed as string.
    in that case it will be a function of 5 parameters i.e. IIF( ArrayX, "==",ArrayZ, ArrayA, Null) or IIF( floatX, ">=", floatY, floatC, Null)
    Pl Let me know How to write Function Templet where Parameters can be float, float* or Null ?

  • @somnathmore1082
    @somnathmore1082 3 ปีที่แล้ว +1

    Video no I watched on simple snippets:19

  • @gubbu8352
    @gubbu8352 3 ปีที่แล้ว

    Tottaly i didn't understand but i understand something 👍

  • @levi25902
    @levi25902 2 ปีที่แล้ว

    Thank You so much,ur vids help sm

  • @LeelosAdventure
    @LeelosAdventure 2 ปีที่แล้ว

    very helpful thank you

  • @muzzysquared
    @muzzysquared 2 ปีที่แล้ว

    Very useful indeed.

  • @oleksandrbondarenko9431
    @oleksandrbondarenko9431 3 ปีที่แล้ว

    You helped me, thanks

  • @tetlleyplus
    @tetlleyplus 4 ปีที่แล้ว +2

    Awesome! you rock!

  • @aswinmanmathans6837
    @aswinmanmathans6837 2 ปีที่แล้ว

    is it necessary to pass the data type like etc..i did watch some lectures w/o that

  • @zakriabacha2477
    @zakriabacha2477 6 ปีที่แล้ว +2

    excellent sir.

    • @SimpleSnippets
      @SimpleSnippets  6 ปีที่แล้ว +1

      Thank you so much buddy. Really happy to see your positive feedback 😋

  • @summayyahashmani2494
    @summayyahashmani2494 4 ปีที่แล้ว +2

    Sir a doubt.
    In my textbook the template defination goes like :
    template
    And u wrote typename
    What are these and do they make any difference???

    • @manojseenivasan8854
      @manojseenivasan8854 4 ปีที่แล้ว +1

      typename is nothing but a class

    • @debeshroy9632
      @debeshroy9632 4 ปีที่แล้ว

      Same..but in new cpp version we should use class as typename will become obsolate

    • @zainulkhan8381
      @zainulkhan8381 4 ปีที่แล้ว

      We can use both

    • @zainulkhan8381
      @zainulkhan8381 4 ปีที่แล้ว

      Either use typename T or class T

    • @hehexd2913
      @hehexd2913 4 ปีที่แล้ว

      @@debeshroy9632 typename will not become obsolete, its better to use typename

  • @sahilprasantachoudhury911
    @sahilprasantachoudhury911 5 ปีที่แล้ว +1

    Class templates starts from 1: 30 . Thank me later 🙏

  • @v.rprasad5377
    @v.rprasad5377 4 ปีที่แล้ว

    5:16
    Why is it not obj1.setData(5) ?

    • @dhruvkhara
      @dhruvkhara 4 ปีที่แล้ว +1

      pele class pass karna padta hai method ke liye badme data type isliye maybe
      .
      .
      .
      .
      .
      .
      .
      .
      ps: new to c++ i am not sure

    • @v.rprasad5377
      @v.rprasad5377 4 ปีที่แล้ว

      @@dhruvkhara thank you for the reply bhai. But during function call we mention the data type. I was wondering why not during the method call of a class.

    • @dhruvkhara
      @dhruvkhara 4 ปีที่แล้ว

      @@v.rprasad5377 maybe because we declared it before,
      like normally one we declare
      int i , j=0
      we don't need to declare data type for i or j again

    • @v.rprasad5377
      @v.rprasad5377 4 ปีที่แล้ว

      @@dhruvkhara yes but they were generic data types. Anyway leave it

    • @bhanugoyal5525
      @bhanugoyal5525 3 ปีที่แล้ว +1

      because we have to initialze the object first. Then after doing this object call any method from the class.

  • @shubhamsonawane967
    @shubhamsonawane967 3 ปีที่แล้ว +1

    Sir plz add videos on c++ STL

  • @vedantghate92
    @vedantghate92 3 ปีที่แล้ว +1

    Bro when we write a function
    void setData( T x)
    {
    kg=x;
    }
    what we did?? please explain

    • @thecountrox
      @thecountrox ปีที่แล้ว

      T here is our datatype placeholder
      since we are passing it as int , T becomes int here so it will be read like : void setData(int x)
      the next line we are setting kg value to x

  • @sharonjoe7535
    @sharonjoe7535 3 ปีที่แล้ว +1

    bro @line 29 you passed 053( for the first compilation)
    but it showed 43(after the first compilation
    how?

  • @saisardesai5548
    @saisardesai5548 5 ปีที่แล้ว +1

    2:33 why are the functions private while the data members in public? Why would anyone want to do that?

    • @helloworldof
      @helloworldof 4 ปีที่แล้ว +1

      It’s like that so that only the functions are able to access the data members

    • @v.rprasad5377
      @v.rprasad5377 4 ปีที่แล้ว

      Just an example to show stacks with elements of different data types.

  • @emirhan1356
    @emirhan1356 4 ปีที่แล้ว

    but this just a basic usage. can you show us what should we do when we want to use 2 class and we need to send parameters. what will be the parameters type

  • @Gandhiboy
    @Gandhiboy 4 ปีที่แล้ว +1

    Thank you so much ❤️

    • @SimpleSnippets
      @SimpleSnippets  4 ปีที่แล้ว

      You’re welcome 😊Please do share the videos and our channel with your friends if you want to genuinely support me & our channel!✌😇

  • @surajsuryawanshi7835
    @surajsuryawanshi7835 4 ปีที่แล้ว +1

    Cool bro

  • @SAG967
    @SAG967 4 ปีที่แล้ว

    Hey will you post a C++ program to find area of a square using class template

  • @rohitdurbha1881
    @rohitdurbha1881 6 ปีที่แล้ว +1

    Stacks are Last In First Out memory not First In Last Out

    • @SimpleSnippets
      @SimpleSnippets  6 ปีที่แล้ว +3

      Yes even you are right but It's just another way of saying it. 👍
      Both mean the same buddy, think over it.

  • @arshmaanali714
    @arshmaanali714 3 ปีที่แล้ว

    what is the difference between stack memory allocation and dynamic memory allocation and which more convenient

    • @ExcellenzaGamer
      @ExcellenzaGamer 2 ปีที่แล้ว

      stack memory allocation is basically when the compiler allocates specific memory before running the program or while during compiling you can say, and dynamic memory allocation is allocation of memory during running of program, or you can call it as runtime allocation of memory. and when it comes to convenience, it depends on two factors, first is the programmer and the second one is requirement, if the programmer thinks the problem can be solved without dynamically allocating the memory he can do it, but if the requirement is such that he cannot do it without dynamic memory allocation, then he must solve it accordingly.

  • @anshumanisharma6751
    @anshumanisharma6751 5 ปีที่แล้ว +1

    Great!!!

    • @SimpleSnippets
      @SimpleSnippets  5 ปีที่แล้ว

      Most welcome buddy, please do share the videos with your friends too. Thats the biggest help and support you can provide to our channel 😇

  • @azdinator
    @azdinator 2 ปีที่แล้ว

    Thank you bro

  • @IshuSingh-k7f
    @IshuSingh-k7f 5 ปีที่แล้ว +1

    why 053 become 43? before you fixed the typo
    Thankyou :D

    • @prachikumari7021
      @prachikumari7021 4 ปีที่แล้ว

      Because whenever we type any number following 0, it is treated as an octal. So here in this case, the template was analogous to int type or decimal so 53 got converted from its octal to decimal form and so we got 43(5x[8^1]+3*[8^0]).

  • @shivajichalise_
    @shivajichalise_ 3 ปีที่แล้ว

    do you have a tutorial on CRTP ?

  • @khankaloo3409
    @khankaloo3409 3 ปีที่แล้ว

    how to use class template using separate files.. i.e .h and srcfile

  • @PiyushKumar-ix9jp
    @PiyushKumar-ix9jp 3 ปีที่แล้ว

    bro can u plz make a video on this template class using file system like i want txt file storing the values

  • @Scottko
    @Scottko 4 ปีที่แล้ว +7

    Guy talks so fast I had to slow it down

    • @SimpleSnippets
      @SimpleSnippets  4 ปีที่แล้ว +4

      Hahah sorry for the high speed. Will keep this in mind in future 😅

  • @muralit.p2954
    @muralit.p2954 3 ปีที่แล้ว

    bro can you do a video for STL also?

  • @manjeshsingh3002
    @manjeshsingh3002 4 ปีที่แล้ว

    Can we write "class" at the place of typename??

  • @saipavank2660
    @saipavank2660 6 ปีที่แล้ว +1

    Good one ....😀

    • @SimpleSnippets
      @SimpleSnippets  6 ปีที่แล้ว

      Thank you so much. Please share the video with your friends and contact as that will be the best help and support for our channel 😇✌

  • @kashishgoel1428
    @kashishgoel1428 5 ปีที่แล้ว +2

    Best

    • @SimpleSnippets
      @SimpleSnippets  5 ปีที่แล้ว +1

      Thank you so much my friend 😊
      Please do share the video with your friends too 😊✌️

  • @kurapatiakhilkumar5314
    @kurapatiakhilkumar5314 5 ปีที่แล้ว +1

    good bro

    • @SimpleSnippets
      @SimpleSnippets  5 ปีที่แล้ว

      Thank you buddy, please do share them with your friends :-)

  • @sumitmhaiskar722
    @sumitmhaiskar722 5 ปีที่แล้ว +2

    bro tu samjta mast h but pls thoda slow baat kar ekdum fatse mat nikal jaa aramse baat aramse samjha thoda dimag me baithege phir baaki sab mast hai bhai tera acha kaam karra hai

    • @SimpleSnippets
      @SimpleSnippets  5 ปีที่แล้ว +1

      Thank you Sumit for this genuine feedback. And yes sometimes I tend to speed up while speaking without knowing. I will make sure to speak slow in future :-)

  • @oshoconner4003
    @oshoconner4003 3 ปีที่แล้ว

    Sir stl ?

  • @aayushadhikari7851
    @aayushadhikari7851 3 ปีที่แล้ว

    GOD level teaching

  • @pawansahu5265
    @pawansahu5265 4 ปีที่แล้ว

    Thanks..

  • @mahesh-jg3zx
    @mahesh-jg3zx 5 ปีที่แล้ว

    Super super super

  • @YashPrajapati-js8zd
    @YashPrajapati-js8zd 5 ปีที่แล้ว +3

    Bhai apke pas itna knowledge he to any job karte ho ya nahi}?

    • @SimpleSnippets
      @SimpleSnippets  5 ปีที่แล้ว +4

      Kyuki ye teaching work main muje khushi mil rahi hai dost. Kaam wahi karo jaha aapka dil se mann lag raha hai. 😇✌

  • @SunitaRani-ys9oy
    @SunitaRani-ys9oy 4 ปีที่แล้ว +2

    Itni speed me kon pdhata h....thoda slow hona chaiye taki kisiko reading ka or sochne ka tym mil ske ...🤨🤨🙄dnt like ur teaching style

    • @SimpleSnippets
      @SimpleSnippets  4 ปีที่แล้ว +1

      Sorry Anil for the high speed. Main future main try karunga ki speed slow rahe. 🙏

  • @melvininfant9295
    @melvininfant9295 6 ปีที่แล้ว +1

    Can u post a video about template overloading

  • @akwithyou1066
    @akwithyou1066 2 ปีที่แล้ว

    tHANKSBRO

  • @ham__edits8
    @ham__edits8 ปีที่แล้ว

    👏

  • @darshandarshan-ph6uk
    @darshandarshan-ph6uk 3 ปีที่แล้ว +1

    please provide twitter hash tag we can promote your worthful channel there publicly

  • @vasusharma_
    @vasusharma_ 5 ปีที่แล้ว

    Sir we want overloading template functions

  • @nashhash4625
    @nashhash4625 7 ปีที่แล้ว +4

    These are the best videos.Please keep uploading
    while(1)
    {
    cout

    • @SimpleSnippets
      @SimpleSnippets  7 ปีที่แล้ว +1

      +Nash Hash thank you so much Nash! Such a creative comment and positive response buddy. Keep sharing the videos with your friends and contacts ✌️
      Follow me on Facebook and Instagram and you can give suggestions about new video tutorials too 😇

  • @VasaMusic438
    @VasaMusic438 4 ปีที่แล้ว +1

    You speak too fast !!!

  • @mrs.patriciathomas-evans9115
    @mrs.patriciathomas-evans9115 4 ปีที่แล้ว

    sing sing sing sing WTF???

  • @letsdoit7083
    @letsdoit7083 ปีที่แล้ว

    you are like just reading the code from some website and typing here, no explanation nothing just straight-on writing the code that too idk weird stuff, sorry but i gotta dislike the video.

  • @kuldipsarvaiya2129
    @kuldipsarvaiya2129 2 ปีที่แล้ว

    You speak too much speedy

  • @masumali8356
    @masumali8356 ปีที่แล้ว +1

    you are the best..........masum

  • @kamyagupta4030
    @kamyagupta4030 2 ปีที่แล้ว

    thank you so much ❤️

  • @rohitdurbha1881
    @rohitdurbha1881 6 ปีที่แล้ว

    Stacks are Last In First Out memory not First In Last Out

  • @_a_r_un_
    @_a_r_un_ 2 ปีที่แล้ว

    Tnq so much ❤️