Access Specifier in C++ | OOP in C++


 
in this video we will discuss how to create Access Specifier in C++ | OOP in C++ - ' Access Specifier ' There are three access specifiers: 1. public members are accessible from outside the class 2. private members cannot be accessed (or viewed) from outside the class 3. protected members cannot be accessed from outside the class, however, they can be accessed in inherited classes.

#include <iostream>
using namespace std;
class MyClass {
  public:    // Public access specifier
    int x;   // Public attribute
  private:   // Private access specifier
    int y;   // Private attribute
};

int main() {
  MyClass myObj;
  myObj.x = 25;  // Allowed (public)
  myObj.y = 50;  // Not allowed (private)
  return 0;
}
► Shopify For Beginners :- https://youtube.com/playlist?list=PLm... ► Google AdSense :- https://www.google.com/adsense/start/ ► Google Cloud Boost Playlist - https://www.youtube.com/playlist?list... ► Google Cloud SQL Playlist:- https://youtube.com/playlist?list=PLm... ► GitHub Playlist - https://youtube.com/playlist?list=PLm... ► Flutter For Beginners :- https://youtube.com/playlist?list=PLm... ► WordPress Free themes For Beginners :- https://youtube.com/playlist?list=PLm... ► HTML & CSS and JAVASCRIPT Projects:- https://youtube.com/playlist?list=PLm... ► C++ For Beginners Playlist :- https://youtube.com/playlist?list=PLm... ► OOP in C++ : https://youtube.com/playlist?list=PLm9Gsf8MIeRfQItd4qclHckYmsnu3gzo7 ► C++ Basic Programs : https://youtube.com/playlist?list=PLm... ► SQL Tutorials For Beginners: https://youtube.com/playlist?list=PLm... 🔁 Facebook: https://www.facebook.com/mscubetechco... 🛑 YouTube : https://www.youtube.com/channel/UC1Gb... #html #css #c++ #cpp #mscubetech #coding #programming #javascript #mscubetech

Post a Comment

0 Comments

Close Menu