Static Data Member And Static Member Function In C++

Поделиться
HTML-код
  • Опубликовано: 4 фев 2025
  • JOIN ME
    -----
    RUclips 🎬 / @cppnuts
    Patreon 🚀 / cppnuts
    COMPLETE PLAYLIST
    ------------
    C++ Tutorial For Beginners: • Introduction To C++
    STL (Standard Template Library): • STL In C++
    ThreadIng In C++: • Multithreading In C++
    Data Structures: • Data Structure
    Algorithms: • Binary Search
    Design Patterns: • Factory Design Pattern...
    Smart Pointers: • Smart Pointer In C++
    C++14: • Digit Separator In C++
    C++17: • std string_view in C++...
    C++ All Type Casts: • static_cast In C++
    INTERVIEW PLAYLIST
    ------------
    C++ Interview Q&A: • Structural Padding & P...
    C++ Interview Q&A For Experienced: • How delete[] Knows How...
    Linked List Interview Questions: • Find Kth Node From Bac...
    BST Interview Questions: • Search Element In Bina...
    Array Interview Questions: • Reverse An Array
    String Interview Questions: • Check String Is Palind...
    Bit Manipulation Questions: • Find Set Bit In Intege...
    Binary Tree Interview Question: • Invert Binary Tree
    Sorting Algorithms: • Bubble Sort
    C++ MCQ: • Video
    C MCQ: • What printf returns af...
    C Interview Questions: • Designated Initializat...
    QUICK SHORT VIDEOS
    -------------
    C++ Short : • C++ Short Videos
    C Short : • Shorts C Programming MCQ
    In this video we will learn about "static data member and static member function" in c++ programming language.
    There are few points about the same as follows:
    1. We can define class members static using "static" keyword.
    2. it can access only static data members. (non-static data member can be accessed but we have to pass the object inside function)
    3. it can access private data of class.
    #cpp #programming #tutorial #coding #cppprogramming #computerscience #softwareengineering

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

  • @cosminmoldovan3444
    @cosminmoldovan3444 4 года назад +9

    Your repetitive explanations are the best man ! I think that is the key for easy learning. I really understood what " static " mean now ! Thank you very much !

  • @sallaklamhayyen9876
    @sallaklamhayyen9876 3 года назад +2

    best and easiest explanation about the topic on youtube
    you are really a real teacher
    thank you so much please continue because we need more

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

      Thanks dude..

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

    This was an amazing video, I couldn’t find a simple video explaining static functions and variables. This helped me tremendously and I hope you continue to post videos like these

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

      Glad it helped!

  • @dwolrdcojp
    @dwolrdcojp 2 года назад +2

    Finally understand the static keyword. Thanks! Great example.

  • @006daredevil
    @006daredevil 2 года назад

    This channel Deserves More subscribers. Awesome Explaination.

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

      Thanks dude..

  • @AniketPanche.
    @AniketPanche. 3 года назад +1

    Watched so many videos for static data member but finally i found this masterpiece 😌

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

    Really amazing sir
    Your all videos are best
    Paid courses too don't have such quality and clear explanation!
    Thanks 🙏🙇 a lot!

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

      Thanks for the comment.
      It means a lot.

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

      Can u plz help me....why Thier is. Special declaration of y in needed outside the class I didn't get it
      Thanks

  • @Shahad99-x3h
    @Shahad99-x3h 4 месяца назад

    Wow! That made it really clear! Thank you!

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

    Really good. Best example to understand the static data member

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

    Superb Explanation Thanks👍❤

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

    This video is really helpful. Thank you very much

  • @JEN-ge1lu
    @JEN-ge1lu 5 лет назад +3

    you are one of the best out here in youtube

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

      Thanks for the encouragement..

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

      Can u plz help me....why Thier is. Special declaration of y in needed outside the class I didn't get it
      Thanks

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

      I totally agree, this guy is saving my college degree
      Thanks Rupesh!

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

    You are awesome, your explanation is toooooooooo good

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

      Thank you so much 😀

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

    Excellent Explanation Sir.

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

    You're the G.O.A.T 🔥🔥🔥🔥🔥🔥🔥

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

    Thanks bro.. as usual nice video... you are the best...

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

      Can u plz help me....why Thier is. Special declaration of y in needed outside the class I didn't get it
      Thanks

    • @181Ravikiran
      @181Ravikiran 4 года назад +1

      @@behindthescene4406 you mean for int Base::y; ??? or you need to do initialization for static member, in global scope, or else you will not be able to point it to same memory.

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

      Thanks ..got it ..

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

    Thank you for chopping into smaller details especially for me that is a slow learner.

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

      Welcome dude .

  • @mystery5868
    @mystery5868 4 дня назад

    Which ide are you using in above video?

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

    Excellent sir

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

    which compiler you are using? btw great video.

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

      This is g++ and editor is sublime text 3

  • @ritesh_puri.
    @ritesh_puri. 3 года назад

    Great explanation sir, recently I face problem due to initializing static variable inside .h

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

    very useful video, thank you. how do we ask specific questions? do you have any forum or blog? i came across some static function used by different cpp files using objects, so i was wondering why static function is used with objects. additionaly, evey c file is sending a different data to the function and function is declared as static inthe called c file.

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

    Great explanation

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

    Thanks buddy for this tutorial.. Please explain Static class also ??

    • @CppNuts
      @CppNuts  5 лет назад +4

      We don't have static class in cpp.

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

    Awesome thank you !

  • @swanlinefrancis7401
    @swanlinefrancis7401 6 лет назад +2

    Thank u ....🙏🙏
    keep going....

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

      You are welcome!!

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

    thankyou so much, these videos are really very helpfull :)

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

    Very good video. Thank you....

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

      You are welcome, thanks for the comment!!

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

    what if we have pragma once in header file. In that case we can define static in header file ?

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

    Sir , which ide u r usin ?

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

      It is sublime text editor 3.

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

    can we declare & initialize static variable in one place inside cpp class?

  • @331sachinkiragi8
    @331sachinkiragi8 2 года назад

    Int a=1;
    Cout

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

    Why do we need static data members and functions? I don't think we do, do we?

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

    great video, thank you!

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

    Hi CppNuts
    How can we calculate number of classes in a hierarchy?
    I have access only my class in the hierarchy.
    Thanks
    Irshad

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

    Nice Video..
    can you explain about internal linkage of static member function. I have some confusion.
    And do static data member also have internal linkage??

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

      Yes it is internal linkage.

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

      internal linkage means other .cpp file will not access it even if file is included.

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

      No if you have included the file then there is no question about becoz every thing will be copied there. And it will work like single cpp file.

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

      Can u plz help me....why Thier is. Special declaration of y in needed outside the class I didn't get it
      Thanks

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

    In which memory static variable is stored?

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

    Hey sir may I know what is meant by b1. X please

  • @ARNABPAL194
    @ARNABPAL194 6 лет назад +2

    Thanks for this ...

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

    What about static variables in functions? Do they act the same as class members.

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

    Are we using Scope resolution for only defining static data members alone? Any other use is there?

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

      scope resolution operator can be used for namespace, member function, to access global variables... etc so as you can see here its job is to resolve the scope that's why it is called scope resolution operator.

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

      CppNuts thank you so much 👍😍

  • @surajsinghsolanki5059
    @surajsinghsolanki5059 10 месяцев назад

    One question: If we can access static data member through non static method of class, then why there is need of static method in the class?

    • @CppNuts
      @CppNuts  10 месяцев назад

      To do a common job for which no object is required.

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

    Hello
    Which IDE is are using??

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

      Sublime text editor 3

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

    Sir why static member function cannot be overloaded?

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

    well done

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

    #include
    using namespace std;
    class Base
    {
    public:
    int x;
    static int y;
    static void showY(){ cout

    • @CppNuts
      @CppNuts  5 лет назад +4

      You forgot to give memory to y.
      Just put static int Base::y;
      In global scope.

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

      @@CppNuts Thanks alot

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

    how can I watch the previuos video yu mentioned? please put link or give its name

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

      What did i mentioned, it is very old video, and i don't have time to watch full video to find that line.
      please let me know if i mentioned something and you remember.

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

    what is use case of static member function?

    • @CppNuts
      @CppNuts  4 года назад +3

      Biggest use is you call them without any object of the class.

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

    All fine but one thing you forgot mention, in which memory creating static variables

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

      thanks man I will create separate video for that.

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

      @@CppNuts where would it be ?

  • @SahilSingh-js9oe
    @SahilSingh-js9oe 5 лет назад +1

    sir are you from india ?

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

      Yes, i am from india, in india.

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

    v nice

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

    Sir clr nhi hai aap jab dusra step sikha raha ho

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

    I can't see

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

    Sir sirf aapna 10minute sikhaya voh pura clr tha baki pura blr hai