What is C++? 
C++ is an object-oriented language. Now lets first know what an object-oriented language is!I will follow the top-down approach.
When we say object oriented it means that we deal with objects here. But what is an object ?
An object is an instance of a class. What is a class? 
A class is a user-defined data structure that actually has some data members and some functions.
Now, what are data members and functions?
Data members are the ingredients of a class that contains some data. 
Functions(known as methods in Java) are a set of operations that are performed according to our need.
For example,  Consider the following code snippet:
int add(int a, int b){
      return a + b;
}
The following code snippet is a function named "add" that has a return type of integer type and takes in 2 parameters of integer type a and b. It returns the sum of a and b. 
Lets see how a class looks:
class Solution{
      int x, y ;
      public:
           int add(int a, int b){
                  return a + b ;
           }
}
The following class has a name Solution with the function as "add" and data members as x and y. Note a and b are not the class members since they will be called from another class.
Comments
Post a Comment