Pages

Tuesday, May 6, 2025

Access modifiers in OOPs

 class Student {

    public:

    //Properties


    string name;

    float cgpa;


    


    //Methods


    void getPercentage() {


        cout << (cgpa*10) << endl;


    }


};




class User{


    int id;


    string username;


    string password;


    string bio; 


    


    void deactivate() {


        cout << "deactivating account\n";


    }


    


    void editBio(string newBio) {


        bio = newBio;


    }


};




int main() {


    Student s1; // objects


    s1.name = "debadattacodes";

    s1.cgpa = 9.0;

    

    cout << s1.cgpa << endl;

    s1.getPercentage();

    

    cout << s1.name << endl;

 

}

No comments:

Post a Comment

how to become red on codeforces by Errichto Algorithms | explained simply in a blog

 Yes. I found an available transcript of the video and summarized it simply. The video is “How To Become Red Coder? (codeforces.com)” by Err...