#include <iostream>
using namespace std;

class Student{
public:
    int id;
private:
    string name;
};

int main(){
    Student a,b,c;

    a.id = 10;
    a.name = "Anas";

    b.id = 20;
    b.name = "Mohammad";

    c.id = 30;
    c.name = "Ali";

}

Function in Class 👌🏻

#include <iostream>
using namespace std;

class Student{
private:
    string Name;

public:
    string SetName(string name){
        Name = name;
        return "Your Name is " + Name;
    }

    string MyName(){
        return Name;
    }
};

int main(){
    Student a;

    cout << a.SetName("Anas") << endl;
    cout << a.MyName() << endl;
    cout << a.SetName("Ali") << endl;
    cout << a.MyName() << endl;

}

Why do I use private: in Class 🙄

#include <iostream>
using namespace std;

class account{
private:
    int MyPassword = 123456;
public:
     string checkPassword(int password){
         if (password == MyPassword)
             return "Hello !";
         else
             return "The Password is Incorrect";
    }
};

int main(){
    account x;

    cout << x.checkPassword(123456) << endl;
    cout << x.checkPassword(123);
		~~cout << x.MyPassword;~~ // error: 'int account::MyPassword' is private within this context
    
}

The purpose of the private: Using a password without accessing it directly