Classes, Public and Private access modifiers in C++ | C++ Tutorials for Beginners #21



►Source Code & Resources: https://codewithharry.com/videos/cpp-tutorials-in-hindi-21
►This video is a part of my C++ playlist: https://www.youtube.com/playlist?list=PLu0W_9lII9agpFUAlPFe_VNSlXW5uE0YL
►For Doubt Solving, Brain Storming Sessions & guaranteed replies, join the channel membership here: https://www.youtube.com/channel/UCeVMnSShP_Iviwkknt83cww/join
►Click here to subscribe – https://www.youtube.com/channel/UCeVMnSShP_Iviwkknt83cww
►Checkout my English channel here: https://www.youtube.com/ProgrammingWithHarry

Best Hindi Videos For Learning Programming:

►Learn Python In One Video – https://www.youtube.com/watch?v=ihk_Xglr164

►Python Complete Course In Hindi – https://www.youtube.com/playlist?list=PLu0W_9lII9agICnT8t4iYVSZ3eykIAOME

►C Language Complete Course In Hindi –

►JavaScript Complete Course In Hindi –

►Learn JavaScript in One Video – https://www.youtube.com/watch?v=onbBV0uFVpo

►Learn PHP In One Video – https://www.youtube.com/watch?v=xW7ro3lwaCI

►Django Complete Course In Hindi –

►Machine Learning Using Python – https://www.youtube.com/playlist?list=PLu0W_9lII9ai6fAMHp-acBmJONT7Y4BSG

►Creating & Hosting A Website (Tech Blog) Using Python – https://www.youtube.com/playlist?list=PLu0W_9lII9agAiWp6Y41ueUKx1VcTRxmf

►Advanced Python Tutorials – https://www.youtube.com/playlist?list=PLu0W_9lII9aiJWQ7VhY712fuimEpQZYp4

►Object Oriented Programming In Python – https://www.youtube.com/playlist?list=PLu0W_9lII9ahfRrhFcoB-4lpp9YaBmdCP

►Python Data Science and Big Data Tutorials – https://www.youtube.com/playlist?list=PLu0W_9lII9agK8pojo23OHiNz3Jm6VQCH

Follow Me On Social Media
►Website (created using Flask) – http://www.codewithharry.com
►Facebook – https://www.facebook.com/CodeWithHarry
►Instagram – https://www.instagram.com/codewithharry/
►Personal Facebook A/c – https://www.facebook.com/geekyharis
Twitter – https://twitter.com/Haris_Is_Here

35 thoughts on “Classes, Public and Private access modifiers in C++ | C++ Tutorials for Beginners #21

  1. include<iostream>

    include<string>

    using namespace std;

    class bank

    {

    private :

    int a;

    public:

    string bankname,accountname;

    void setdata(int a);

    void getdata();{

    cout<<"my salary is"<<a<<endl;

    cout<<"my bankname is"<<bankname<<endl;

    cout<<"my accountname is"<<accountname<<endl;

    }

    };

    void bank :: setdata(int a);{

    salary=a;

    }

    int main(){

    bank ash;

    ash.bankname="sbi";

    ash.accountname="ashsbi";

    ash.setdata(2);

    ash.getdata();

    return 0;

    }

    can anyone tell me what is error in this code….if possible can anyone rewrite this code in correct manner

  2. class Dog{

    private:

    string name;

    int id;

    public:

    string owner;

    void setdata(string name ,int id); // function declaration

    void getdata(){

    cout<<"name of the dog is "<<name<<endl;

    cout<<"id of the dog is "<<id<<endl;

    cout<<"owner of the dog is "<<owner<<endl;

    }

    };

    //* defination of the function setdata

    void Dog :: setdata(string name1 ,int id1){

    name = name1;

    id = id1;

    }

    int main(){

    Dog kutta;

    Mohit.setdata("Bull Dog" , 5236);

    Mohit.owner= "kutte ka malik";

    Mohit.getdata();

    return 0;

    }

  3. class students

    {

    private:

    int mereMarks, meriAttendence;

    public:

    int instagram, whatsapp;

    void setAttendence(int everyday, int except_sat_sun);

    void WriteAssignments(int subjects, int pages);

    }

  4. Q 1: Write a C++ function “addition” that will take two arguments “istVal” and “secVal” as integer

    arguments and the function will add the values of “istVal” and “secVal” and return the result to

    the calling statement in main function.

  5. sir isme pointer kaise use kru
    Create a class Student with data members such as roll, name and

    grade. Write a program to access records of a student using

    pointers to class object. Write required member functions to take

    input and display the record of a student.

Leave a Reply

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