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

►Source Code & Resources:
►This video is a part of my C++ playlist:
►For Doubt Solving, Brain Storming Sessions & guaranteed replies, join the channel membership here:
►Click here to subscribe –
►Checkout my English channel here:

Best Hindi Videos For Learning Programming:

►Learn Python In One Video –

►Python Complete Course In Hindi –

►C Language Complete Course In Hindi –

►JavaScript Complete Course In Hindi –

►Learn JavaScript in One Video –

►Learn PHP In One Video –

►Django Complete Course In Hindi –

►Machine Learning Using Python –

►Creating & Hosting A Website (Tech Blog) Using Python –

►Advanced Python Tutorials –

►Object Oriented Programming In Python –

►Python Data Science and Big Data Tutorials –

Follow Me On Social Media
►Website (created using Flask) –
►Facebook –
►Instagram –
►Personal Facebook A/c –
Twitter –

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

  1. include<iostream>


    using namespace std;

    class bank


    private :

    int a;


    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);{



    int main(){

    bank ash;





    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{


    string name;

    int id;


    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";


    return 0;


  3. class students



    int mereMarks, meriAttendence;


    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 *