access to info

                Never    
C++
       
#include<iostream>
using namespace std;
class number
{
public:
    string name = "Thasin";
    int num = 100;
    void setinfo(){
      cout<<"Enter name:\t";
    cin>>name;
      cout<<"Enter number:\t";
    cin>>num;
      cout<<"__________________"<<endl;}
      void view(){
      cout<<"Name: "<<name<<" \t"<<endl;
   cout<<"Number: "<<num<<" \t"<<endl;
      cout<<"__________________"<<endl;}
friend void buddy();//global function as friend
 };
 void buddy(){
 number ob1;
 ob1.view();}//access to private data number
int main(){

            cout<<"If you have authority to change type 1. Else type 2 to view info."<<endl;
            int o=0,p=0;
            cin>> o;
            if(o==1){
                 cout<<"Inter password."<<endl;
                 cin>>p;
                 if(p==401){
                    cout<<"If you want to view press 3."<<endl;
                    cout<<"If you want to edit press 4."<<endl;
                    int s=0;
                    cin>>s;
                    if(s==3){number ob1; ob1.view();}
                    if(s==4){number ob1; ob1.setinfo(); cout<<"New info."<<endl; ob1.view();}
                 }
            }
            if(o==2){number ob1; ob1.view();}
return 0;
         }

Raw Text