What is the relationship between a class and an object?

Technology CommunityCategory: OOPWhat is the relationship between a class and an object?
VietMX Staff asked 3 years ago

A class acts as a blue-print that defines the properties, states, and behaviors that are common to a number of objects. An object is an instance of the class. For example, you have a class called Vehicle and Car is the object of that class. You can create any number of objects for the class named Vehicle, such as VanTruck, and Auto.

The new operator is used to create an object of a class. When an object of a class is instantiated, the system allocates memory for every data member that is present in the class.