data classes and abstraction.

i have not understood classes in c++.please explain it to me.

Comments

  • : i have not understood classes in c++.please explain it to me.
    :

    Very simply, a class is just a way of grouping together objects and functions for a common purpose. For example, a student file at a university might contain the student's name, address, city, state, zip code, and telephone number. so the class could be constructed like this:
    [code]
    #include

    class CStudent
    {
    public:
    CStudent(); // constructor
    ~CStudent(); // destructor
    void PutName(string& n) {name = n;}
    string GetName() {return name;}

    protected:
    std::string name;
    std::string address;
    std::string city;
    std::string state;
    std::string zip_code;
    std::string phone;
    };
    [/code]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion