Pages

Tuesday, May 6, 2025

Classes & Objects in OOPs

in Leetcode Playground: 


class Student {

    //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

    cout << sizeof(s1) << endl;

    

    Student s2; // objects

    cout << sizeof(s2) << 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...