Static Data Members in C++ & Static Member Functions in C++|C++ programming tutorials for Beginners

Поделиться
HTML-код
  • Опубликовано: 25 июл 2024
  • Support Simple Snippets by Donations -
    Google Pay UPI ID - tanmaysakpal11@okicici
    PayPal - paypal.me/tanmaysakpal11
    --------------------------------------------------------------------------------------------- In this video tutorial we will understand the concept of static data members in c++ and static member functions in c++.
    Static Data members in C++_
    A static member is shared by all objects of the class.
    All static data is initialized to zero when the first object is created, if no other initialization is present.
    We can't put it in the class definition but it can be initialized outside the class using the scope resolution operator :: to identify which class it belongs to.
    When we declare a member of a class as static it means no matter how many objects of the class are created, there is only one copy of the static member.
    Static Member functions in C++
    By declaring a member function as static, you make it independent of any particular object of the class. A static member function can be called even if no objects of the class exist and the static functions are accessed using only the class name and the scope resolution operator (::)
    A static member function can only access static data member, other static member functions and any other functions from outside the class.
    Static member functions have a class scope and they do not have access to the this pointer of the class.
    You could use a static member function to determine whether some objects of the class have been created or not.
    Static Members & Member Functions in C++ Theory Article - simplesnippets.tech/static-me...
    Download Dev C++ IDE : sourceforge.net/projects/orwe...
    Download C++ Android App : play.google.com/store/apps/de...
    Simple Snippets Official Website -
    simplesnippets.tech/
    Simple Snippets on Facebook-
    / simplesnippets
    Simple Snippets on Instagram-
    / simplesnipp. .
    Simple Snippets Google Plus Page-
    plus.google.com/+SimpleSnippets
    Simple Snippets email ID-
    simplesnippetsinfo@gmail.com
    For Classroom Coaching in Mumbai for Programming & other IT/CS Subjects Checkout UpSkill Infotech - upskill.tech/
    UpSkill is an Ed-Tech Company / Coaching Centre for Information Technology / Computer Science oriented courses and offer coacing for various Degree courses like BSc.IT, BSc.CS, BCA, MSc.IT, MSc.CS, MCA etc.
    Contact via email /call / FB /Whatsapp for more info
    email - upskillinfotech@gmail.com
    We also Provide Certification courses like -
    Android Development
    Web Development
    Java Developer Course
    .NET Developer Course
    Check us out on Social media platforms like Facebook, Instagram, Google etc
    Facebook page - / upskillinfotech
    Insta page - / upskill_infotech
    Google Maps - goo.gl/maps/vjNtZazLzW82

Комментарии • 106

  • @SimpleSnippets
    @SimpleSnippets  4 года назад +12

    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 ✌

    • @dariuskasen9229
      @dariuskasen9229 2 года назад

      Sorry to be so off topic but does anyone know of a tool to get back into an instagram account??
      I was dumb lost my password. I appreciate any tips you can give me

  • @Selva-bx9iy
    @Selva-bx9iy 4 года назад +23

    Very young and experienced teacher...🙃🙃🙃

    • @SimpleSnippets
      @SimpleSnippets  4 года назад +1

      Thank you buddy, please do Subscribe to our channel as we have a lot tech educational content which you'll surely like. Also please do share our channel and videos with your friends too, that's the biggest help and support you can provide buddy ✌️

  • @vengalrao5772
    @vengalrao5772 2 года назад +1

    No words ! Thanks a lot 😇

  • @malikasingal6255
    @malikasingal6255 3 года назад +1

    I watch this video 2 times , now I understand very well, all my doubts have cleared, Thank you so much

  • @omkale3132
    @omkale3132 5 лет назад +2

    your videos were really helpful for my practical exam on one day before thanks

    • @SimpleSnippets
      @SimpleSnippets  5 лет назад

      Thank you so much Om😇. Very happy to hear this from you. Please do share the videos with your friends too 🙏 it'll be very helpful 😇

  • @adityamahesh1179
    @adityamahesh1179 5 лет назад +1

    You are awesome you are great!! And the thing you are doing is very kind from.your side really man I easily understood this!!!

    • @SimpleSnippets
      @SimpleSnippets  5 лет назад

      Most welcome aditya 😊 I'm very glad to hear this from you bro. I would request you to please share this video with your friends too buddy. That's the biggest help and support for our channel 🤟😊

  • @gauravdeshmukh3674
    @gauravdeshmukh3674 3 года назад +1

    thanks for this playlist

  • @Pradhee26
    @Pradhee26 6 месяцев назад +1

    Loved it!

  • @ayusheez1678
    @ayusheez1678 7 месяцев назад +1

    All doubts are cleared thanx

  • @tekina4493
    @tekina4493 3 года назад +3

    your video is embedded in Chandigarh University course material, Kudos!

    • @SimpleSnippets
      @SimpleSnippets  3 года назад

      Wow I'm glad to know this🤟 would love it if you could share a link so that I can check it out😊

  • @heartsonny
    @heartsonny 2 года назад

    great explanation thanks

  • @mansijain7913
    @mansijain7913 5 лет назад +7

    Ur way of explaining is awesome and really helpful.. Keep uploading more such videos..

    • @SimpleSnippets
      @SimpleSnippets  5 лет назад

      Hello Mansi, thank you so much for such a wonderful feedback 😇😊
      And yes I'll keep making many more such educational content ✌️
      I would request you to please share the videos with your friends and contacts 😇✌️ that'll be the best help and support for everyone 😊

  • @i1JayChaudhary
    @i1JayChaudhary Месяц назад +1

    Thanks🎉

  • @shubhasriallam5143
    @shubhasriallam5143 4 года назад +4

    Can u give an example of static data members and member functions without using constructors

  • @aarjavbaxi2299
    @aarjavbaxi2299 3 года назад

    Is there any need of declaring the int x in the program..? Because I did not find a reason to declare it...can you pls explain?

  • @shreyasachar5528
    @shreyasachar5528 3 года назад +6

    Jenny's lectures and simple snippets ❤️❤️ONE OF THE WAY TO LEARN AND UNDERSTAND CONCEPTS ❤️

  • @satishkanakappanavar8531
    @satishkanakappanavar8531 5 лет назад +3

    You are helping very much to many students

    • @SimpleSnippets
      @SimpleSnippets  5 лет назад

      Thank you so much Satish, this really makes me very happy that I'm able to contribute and share my knowledge with so many people ✌️🙏
      Keep sharing and keep up the support ❤️

  • @mahesh-jg3zx
    @mahesh-jg3zx 5 лет назад

    Sir what is the use of scope resolution

  • @smitsoni173rdb4
    @smitsoni173rdb4 2 года назад

    Sir please explain the return statement, return optional in void function or return required in non void function

  • @satyajeetjagtap7628
    @satyajeetjagtap7628 Год назад

    you are just awesome bro keep it up

  • @vijaysinghchauhan7079
    @vijaysinghchauhan7079 4 года назад +6

    I found no particular reason for using the integer variable x in the static data member program.
    Anyways Thank You.

  • @ayra_2001
    @ayra_2001 Год назад +1

    Thanks a lot 💙

  • @christinestephen8194
    @christinestephen8194 2 года назад

    thankssss a ton

  • @spraygodgamer6539
    @spraygodgamer6539 6 месяцев назад +1

    very informative and well explained .. Thanks Simple Snippets 👍❤

  • @kunalpandit6169
    @kunalpandit6169 2 года назад

    Awesome!

  • @nalamanunay2163
    @nalamanunay2163 3 года назад

    in last example count was declared as private but it intialized from out side class it was showing error for me

  • @masumali8356
    @masumali8356 Год назад

    you are the best....masum

  • @rikzingchopelbhutia7350
    @rikzingchopelbhutia7350 2 года назад

    Nice man

  • @jamesnash9675
    @jamesnash9675 2 года назад

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

  • @kalashjain8647
    @kalashjain8647 4 года назад +2

    this video clarified almost all my doubts and was really helpful. so thank you .

    • @SimpleSnippets
      @SimpleSnippets  4 года назад +1

      Most welcome kalash 😊 I'm very happy to hear this from you. I would request you to please share the videos with your friends too. ✌️ That's the biggest help & support for everyone 😁

    • @kalashjain8647
      @kalashjain8647 4 года назад +1

      @@SimpleSnippets i will surely do . looking forward to more videos from your channel

    • @SimpleSnippets
      @SimpleSnippets  4 года назад

      @@kalashjain8647 there are 400+ videos on our channel bro please check it out. You will find many helpful things 😁🤘

  • @RaiMuhammadArslan786
    @RaiMuhammadArslan786 5 лет назад +2

    Thanks!!!

  • @tarekradwan8661
    @tarekradwan8661 4 года назад +2

    why is static needed to keep a count of the objects although declaring n objects will call the default constructor n times ?

    • @SimpleSnippets
      @SimpleSnippets  4 года назад +4

      Good question. Because static variable will only be created once no matter how many times the constructor will be called. Hence static variables are class level an not object level. Thus they can be used very well to keep a track of no of objects by simply incrementing the counter variable value in the constructor. ✌️

  • @nidhinhari8397
    @nidhinhari8397 5 лет назад +2

    Thank you sir

  • @shubhamtiwari7704
    @shubhamtiwari7704 2 месяца назад

    Hi can anyone explain me why the below is valid ?
    Class Xyz{
    static XYZ instance;
    };
    i couldn't find any proper explaination till now

  • @chanvithapraveen1983
    @chanvithapraveen1983 3 года назад

    1K th like by me...Thanks

  • @urmadhu6367
    @urmadhu6367 5 лет назад +3

    Good explaining keep rocking

    • @SimpleSnippets
      @SimpleSnippets  5 лет назад

      Thank you so much brother. Please share the video✌️ and keep up the support 😇

    • @urmadhu6367
      @urmadhu6367 5 лет назад

      @@SimpleSnippets ok bro

  • @chandupeddi7312
    @chandupeddi7312 6 лет назад +3

    Excellent bro

    • @SimpleSnippets
      @SimpleSnippets  6 лет назад +1

      Thank you very much buddy, Please share this video with your friends and contacts because that will be the best help and support for our channel 😇✌

    • @chandupeddi7312
      @chandupeddi7312 6 лет назад

      Kk bro

  • @sarmadnadeem_
    @sarmadnadeem_ 5 лет назад +1

    Thank you :)

  • @electrotsmishar
    @electrotsmishar 4 года назад +1

    Nice explanation

  • @gamingcrew4217
    @gamingcrew4217 4 года назад

    you are superb bro

  • @nidhinhari8397
    @nidhinhari8397 5 лет назад +1

    What will happen if we initialize(3:24) "int myclass::count;"

    • @navaneethsuresh2049
      @navaneethsuresh2049 3 года назад

      Since we don't give a value, it initializes a value of 0 by default.

  • @akashwagh6733
    @akashwagh6733 4 года назад +1

    ayyy simple snippet bahut achha kaam karta hai re tum

    • @SimpleSnippets
      @SimpleSnippets  4 года назад +1

      Hahaha shukriya dost ❤️ this sounded like that Munna Bhai mbbs scene. Tum bohot mast kaam karta Wala 😆✌️

    • @akashwagh6733
      @akashwagh6733 4 года назад +1

      It's the same 😅✌️

    • @SimpleSnippets
      @SimpleSnippets  4 года назад +1

      @@akashwagh6733 hehe thought so. Also please do share the video with your friends too buddy. That'll be huge help 😁

    • @akashwagh6733
      @akashwagh6733 4 года назад +1

      Definitely ✌️✌️

    • @SimpleSnippets
      @SimpleSnippets  4 года назад

      @@akashwagh6733 thank you brother! Means a lot ❤️

  • @ajayraj4911
    @ajayraj4911 4 года назад +1

    awsm

    • @SimpleSnippets
      @SimpleSnippets  4 года назад

      Thanks bro. Please share the video with you friends 😇

  • @darshanrs491
    @darshanrs491 4 года назад +1

    Can u tell y we need "using namespace std"

    • @SimpleSnippets
      @SimpleSnippets  4 года назад

      Good question, here is a link to your answer - www.learncpp.com/cpp-tutorial/naming-conflicts-and-the-std-namespace/

    • @sauravsajeev1915
      @sauravsajeev1915 4 года назад +1

      Because you need to specify a standard io stream to start inputting and outputting

  • @aravindhanrppeftaiqvbc1325
    @aravindhanrppeftaiqvbc1325 5 лет назад +1

    Do u do java tutorials also sir??

    • @SimpleSnippets
      @SimpleSnippets  5 лет назад

      Yes buddy check on my channel. But it's on core Java for now

  • @kothagorlalokesh7591
    @kothagorlalokesh7591 4 года назад +1

    Bro.ur explaination was extraordinary. but explain some slowly bro. We can't getting u🙏🙏

    • @SimpleSnippets
      @SimpleSnippets  4 года назад

      Thank you so much for the compliments bro, and yes I will reduce my speed in future videos. 😇

  • @rishabh6051
    @rishabh6051 3 года назад

    this video really helped

  • @Skkskk702
    @Skkskk702 3 года назад

    super explaination!!

  • @ashutoshdangi6833
    @ashutoshdangi6833 4 года назад +1

    Well explained 👍

    • @SimpleSnippets
      @SimpleSnippets  4 года назад

      Thank you so much Ashutosh, really glad to hear this from you. Please do subscribe to this channel & share the content with your friends too. That will be the biggest help & support 😇

  • @ProjectsWithGuidence
    @ProjectsWithGuidence 3 года назад +1

    Good explanation 👏 👍

  • @meneshhdhakate608
    @meneshhdhakate608 4 года назад +1

    Plz slow your speed , else your explanation wonderful

  • @dinesh.p8642
    @dinesh.p8642 4 года назад +1

    Tanmay, bro,,,if would be more helpful if u go with some slow pace....ur clarity is also awesome....really helpful.
    Love you..

    • @SimpleSnippets
      @SimpleSnippets  4 года назад

      Hey Dinesh, sorry for my speed bro. Sometimes I just lose track of my speed and go with the flow 😅
      I will take better care of this in future for sure 😊

  • @babbubaliga2736
    @babbubaliga2736 6 лет назад +6

    Why did u stop uploading man?

    • @SimpleSnippets
      @SimpleSnippets  6 лет назад +4

      Hey hi, sorry for the delay buddy was busy with other work. will upload the next tutorial mostly by tomorrow or day after tomorrow. ✌

    • @zakimohas
      @zakimohas 5 лет назад +3

      Thanka bro keep going

    • @SimpleSnippets
      @SimpleSnippets  5 лет назад +3

      Thank you so much bro. Happy to hear your feedback. Do share the videos with your friends and contacts too. That'll be the best help and support 😇

  • @AnkushKumar-mk8ns
    @AnkushKumar-mk8ns 3 года назад

    Nicely explained

  • @sathwikkolli4565
    @sathwikkolli4565 3 года назад +1

    It would be very good if you could slow down the pace😅

    • @SimpleSnippets
      @SimpleSnippets  3 года назад

      I will keep that in mind in future video 😊

  • @backeyam5269
    @backeyam5269 2 года назад

    Main cls therila

  • @hritikbhatnagar9616
    @hritikbhatnagar9616 Год назад

    Itta fast

  • @mayanksingh7501
    @mayanksingh7501 4 года назад +1

    can you just press the keys less forcefully. It sounds like your keys are crying man.

    • @SimpleSnippets
      @SimpleSnippets  4 года назад

      Lmao 😂 😂 actually the microphone is on the desk as well so that elevates the sound. But yeah in general I press them hard 😂 there's a weird satisfaction I guess by nerds! 😛

  • @kaushaltiwari1286
    @kaushaltiwari1286 3 года назад +1

    learning c++ from professors???? idhar aoo sab samjhega

    • @SimpleSnippets
      @SimpleSnippets  3 года назад +1

      Hahahah Thanks Kaushal, share this playlist with your friends too 😇

    • @kaushaltiwari1286
      @kaushaltiwari1286 3 года назад

      @@SimpleSnippets hiii tanmay glad you replied can you explain file handling a bit more please

  • @ishuyadav4878
    @ishuyadav4878 2 месяца назад

    Bhai Hindi 😢