Creating Variables and Accessing them in Methods in a Class

This video tutorial explains how to create properties or the variables in a class and how to access it from the methods of that class.
You will learn what are the access specifiers, how to create a variable, how to access the variable from the methods, how to initialize the variables in detail with example.

source code for this tutorial

#include <iostream>
#include <string>

using namespace std;
class HumanBeing{
    string name;
    void introduce(){
        cout << "hi i am "<<name<<endl;;
int main()
    HumanBeing anil; = "anil";

    HumanBeing anjali; = "anjali";

    return 0;

Back To Top