Static Data Member And Static Member Function In C++

Поділитися
Вставка
  • Опубліковано 19 вер 2024
  • JOIN ME
    -----
    UA-cam 🎬 / @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

КОМЕНТАРІ • 98

  • @cosminmoldovan3444
    @cosminmoldovan3444 3 роки тому +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 !

  • @rickyguerrero8618
    @rickyguerrero8618 2 роки тому +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  2 роки тому

      Glad it helped!

  • @sallaklamhayyen9876
    @sallaklamhayyen9876 2 роки тому +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

  • @dwolrdcojp
    @dwolrdcojp 2 роки тому +2

    Finally understand the static keyword. Thanks! Great example.

  • @AniketPanche.
    @AniketPanche. 3 роки тому +2

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

    • @CppNuts
      @CppNuts  3 роки тому

      Thanks..

    • @mba2ceo
      @mba2ceo 2 роки тому

      @@CppNuts U R azum :) Best teacher I ever had ;) Best wishes

  • @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

  • @jananit7399
    @jananit7399 4 роки тому +1

    Really good. Best example to understand the static data member

  • @JEN-ge1lu
    @JEN-ge1lu 4 роки тому +3

    you are one of the best out here in youtube

    • @CppNuts
      @CppNuts  4 роки тому +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!

  • @006daredevil
    @006daredevil Рік тому

    This channel Deserves More subscribers. Awesome Explaination.

  • @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 ..

  • @umadhu8063
    @umadhu8063 3 роки тому

    You are awesome, your explanation is toooooooooo good

    • @CppNuts
      @CppNuts  3 роки тому

      Thank you so much 😀

  • @gumaryae
    @gumaryae Рік тому

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

  • @kamaldevarapalli2895
    @kamaldevarapalli2895 Рік тому

    Excellent sir

  • @MrSrimagesh
    @MrSrimagesh 3 роки тому

    Excellent Explanation Sir.

  • @pranit1243
    @pranit1243 Рік тому

    Superb Explanation Thanks👍❤

  • @bhadriramlella7697
    @bhadriramlella7697 Рік тому

    This video is really helpful. Thank you very much

  • @regienaldcabanamontalvo509
    @regienaldcabanamontalvo509 2 роки тому

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

    • @CppNuts
      @CppNuts  2 роки тому

      Welcome dude .

  • @mozeidan6481
    @mozeidan6481 2 роки тому

    Great explanation

  • @swanlinefrancis7401
    @swanlinefrancis7401 5 років тому +2

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

    • @CppNuts
      @CppNuts  5 років тому

      You are welcome!!

  • @rogvilchis2853
    @rogvilchis2853 Рік тому

    Awesome thank you !

  • @ARNABPAL194
    @ARNABPAL194 6 років тому +2

    Thanks for this ...

  • @ritesh_puri.
    @ritesh_puri. 3 роки тому

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

  • @cid007007
    @cid007007 4 роки тому +2

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

    • @CppNuts
      @CppNuts  4 роки тому +4

      We don't have static class in cpp.

  • @331sachinkiragi8
    @331sachinkiragi8 Рік тому

    Int a=1;
    Cout

  • @baskaranbaluchamy3667
    @baskaranbaluchamy3667 5 років тому +1

    Very good video. Thank you....

    • @CppNuts
      @CppNuts  5 років тому +1

      You are welcome, thanks for the comment!!

  • @cid007007
    @cid007007 4 роки тому +2

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

    • @CppNuts
      @CppNuts  4 роки тому +4

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

    • @cid007007
      @cid007007 4 роки тому +1

      @@CppNuts Thanks alot

  • @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

  • @Jam18123
    @Jam18123 Рік тому

    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.

  • @levth21
    @levth21 3 роки тому

    great video, thank you!

  • @asifmahmood9358
    @asifmahmood9358 4 роки тому +1

    well done

  • @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

  • @neghatnazir1668
    @neghatnazir1668 4 роки тому

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

  • @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 👍😍

  • @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

  • @kipa_chu
    @kipa_chu 2 роки тому

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

  • @surajsinghsolanki5059
    @surajsinghsolanki5059 6 місяців тому

    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  6 місяців тому

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

  • @nitishbidwe1108
    @nitishbidwe1108 3 роки тому

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

  • @grayson3881
    @grayson3881 2 роки тому

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

  • @mehularora3234
    @mehularora3234 4 роки тому +2

    Sir , which ide u r usin ?

    • @CppNuts
      @CppNuts  4 роки тому

      It is sublime text editor 3.

  • @Jk_Vadaviya
    @Jk_Vadaviya 5 років тому +1

    Hello
    Which IDE is are using??

    • @CppNuts
      @CppNuts  5 років тому

      Sublime text editor 3

  • @vasulaxmana6672
    @vasulaxmana6672 3 роки тому

    In which memory static variable is stored?

  • @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 2 роки тому

      @@CppNuts where would it be ?

  • @atharvadharmadhikari3612
    @atharvadharmadhikari3612 4 роки тому

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

  • @pragyashrivastava4382
    @pragyashrivastava4382 2 роки тому

    v nice

  • @chaitanyagujarathi4318
    @chaitanyagujarathi4318 3 роки тому

    Sir why static member function cannot be overloaded?

  • @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.

  • @SahilSingh-js9oe
    @SahilSingh-js9oe 4 роки тому +1

    sir are you from india ?

    • @CppNuts
      @CppNuts  4 роки тому +1

      Yes, i am from india, in india.

  • @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.

  • @ganesh4406
    @ganesh4406 3 роки тому

    I can't see

  • @ganesh4406
    @ganesh4406 3 роки тому

    Sir clr nhi hai aap jab dusra step sikha raha ho

  • @ganesh4406
    @ganesh4406 3 роки тому

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