1.

Object-Oriented Programming

Answer»
  • Class
class City {
// Attribute
string name;
int population;
public:
// Method
void increase_population() {
population++;
}
};

In C++, a class is the fundamental building block of Object-Oriented programming. A class typically consists of:


  1. Attributes, often called member data, are data about a specific instance of a class.

  2. Member functions, often known as methods, are functions that are present in the class.

  • Objects
City Mumbai;

An object is an instance of a class that encapsulates its data and member functions. The above code creates an instance of the class City named Mumbai.




Discussion

No Comment Found