web analytics


The major destinations of Class and object in c++ are given below:-

The class is used to create the blueprint or architecture. Class is the combination of data member and member function.Class is a user-defined data type, which holds its own data members and member functions or method, which can be accessed and used by creating an instance or object of that class.

For Example:- Consider the class of College. There may be many different types of college present with the different name but all of them will provide a common property like study, library, id card.o here College is the class and study, library, id card are their properties.


An Object is an instance of a class. Object allocates memory but class does not allocate memory.

Defining the class:-

A class is defined in C++ using class keyword and followed by the name of the class. The body of the class is defined inside the bracket and terminated by a semicolon at the end.

Class and object in c++

Declaring Object:-

To use the data and access the function we need to declare the object.


ClassName ObjectName;

What is the difference between method inside class and method outside class?

Method can be defined inside the class and outside the class.

Method defined inside the call are by default inline, but method outside the class are not by default inline.

To define the method outside the class:

  • first, define the prototype inside the class.
  • second, define the method outside the class using class name and using scope resolution operator(::)


Related Posts

Leave a Reply

Your email address will not be published.