#include<iostream> #include<conio.h> using namespace std;
class class_name { public: int var1; int func1(){ return var1; } private: int var2; int func2(){ return var2; } protected: int var3; int func3(){ return var3; } }; int main() { class_name temp1; //initializing a variable temp1 of type class_name temp1.var1 = 5; //allowed because it is public member variable //temp1.var2 = 10; //not allowed because it is private member variable //temp1.var3 = 10; //not allowed because it is protected member variable cout << temp1.func1(); //allowed because it is public member function //cout << temp1.func2(); //not allowed as it is a private member function //cout << temp1.func3(); //not allowed as it is a protected member function cout << endl; }