LEC: 16

CLASS and OBJECTS




Source Code

/*CLASS:

It is a user-defined data type, which holds its own data members and member functions,

which can be accessed and used by creating an instance of that class.

A C++ class is like a blueprint for an object.


OBJECTS:

An Object is an instance of a Class. When a class is defined,

no memory is allocated but when it's object instantiated memory is allocated.


SYNTAX:

class class_name1{

-----data members

---------function

};


int main()

{

    class_name1 o1;

    int a;

}

*/

#include<iostream>

using namespace std;

class Student{

    //private :

    int a=9,b=7;

    public:

    void putdata()

    {

        cout<<"value of a "<<a<< " and b : "<<b;

    }


};

int main()

{

    Student O1;

    O1.putdata();

    return 0;

}



Comments

Popular posts from this blog

RunwayWithCode

web development Lectures

C++ Lectures