Skip to main content

How to start learning Web-development

Encapasulation , Abstration , Polymorphism , Inheritance in c++

 Encapasulation in c++ :-

It is defined as when you wrap and bind all related data together in a single form or in a single unit or you can defined as binding of data together and manipulating it are called encapasulation in C++ .

For Example :
If there is a three department in a company are Finance , sale , research department  finance department handle all finance related data and sales department handle sale related data if finance department needs information about any other section they need permission of head of the department to access it  this called encapasulation . this also lead data abstraction or data hiding


#include <iostream>
using namespace std;

class container
{
private:
    // data hidden from outside world
    int x;

public:
    void given(int a)
    {
        x = a;
    }

    int display()
    {
        return x;
    }
};

int main()
{
    container value;
    int a;
    cin >> a;

    value.given(a);
    cout<<"Output will be :"<<endl;
    cout << value.display();
    return 0;
}


output -
12 
Output will be :
12

 Abstraction in c++ :-

The meaning of data abstraction is it display only essential information and hiding all details . data abstraction refer to providing only essential information about an data to the outside world and hide all the background detail  that called Abstraction in c++.

For Example :
A man visit a website for fill form and they fill it and submit it but they don't know background work how they submit it or how it work.

#include <iostream>
using namespace std;
class container
{
private:
    int abc; // private variables
public:
    void sum()
    {
        cout << "Enter two values : ";
        cin >> a >> b;
        c = a * b;
        cout << "multiplication of two values is: " << c << endl;
    }
};
int main()
{
    container one;
    one.sum();
    return 0;
}

output -
Enter two values : 12
12
multiplication of two values is: 144

Polymorphism in c++ :-

Polymorphism means if we call a member function it will cause a different function to be executed . we can define it as the ability of a message to be displayed in more then one form.
it is called polymorphism in c++

For Example : 
a person the person will be father , son , brother at a same time but behave differently according to situation so its example of polymorphism in c++

this code is example 
#include <iostream>
using namespace std;
class base                                
  {  
       int a;  
       public:  
       void a()  
       {   
             cout<< "Class base ";  
        }  
  };  
class derived : public base                       
{  
    int b;  
    public:  
   void a()  
  {  
        cout<<"Class derived";  
  }  
};  
int main()
{
    ...
    return 0;
}

Inheritance in c++ :-

The capability of a class to derived property and character from other class are called inheritance in c++

For Example :
if we have two type of float variable and three type of float variable and we called both with different function for sum and there Parameters are different but working are same .


Program of function in c++ languages -

#include<iostream>
using namespace std;

// Defining the function here 
void function(int a , int b) 
{
    cout<<"First value of function is:"<<a<<endl;
    cout<<"Second value of function is:"<<b<<endl;
}
int main()
{
int A;
int B;
cout<<"Enter the value of a:"<<endl;
cin>>A;
cout<<"Enter the value of b:"<<endl;
cin>>B;
// calling the function here
function(A,B);
return 0;
}


Comments

Popular posts from this blog

Why we learn REACT JS in web development

 REACT JS in web development - why we use it ? we learn REACT JS in web development because it help us to write less code and make more efficient  website because it divide code into many component which was which help us to to write less code and make more efficient work in less time you can say it is time saver if you don't want to write code from base or say scratch react js is reliable for us and very efficient for web development . What is Component means ? The meaning of component is you say in simple language is react divide the code of website let say if we want to make a website and we want to use a code repeatly so we have to write the again and again but if you was use component you have to write code at ones and use it by import it again and again you can work very efficiently and fast  What we have to do in react  In react we have to convert html form language into JSX form language and if you think how we can do this so their is many option are availabl...

Tutorial 10 text align , decoration etc explaining

 Text in Css - 1.Text color -     here we can set color in text for making them more enhancive or if we want required to change in color of text it work perfectly  syntax - color : red; OUTPUT - text color is change to red 2.Text alignment -     It is used for align the text according to the requirement and their situation we align text at center , right , left etc syntax - text-align:center; 3.Text decoration-     It is to decorate the text let if we want to underline in text then we use text decoration and make it on the line  syntax - text-decoration: underline; OUTPUT - text have an underline decoration 4.Text transformation -  In this we transform letters into uppercase , lowercase and capitalization means if the letter is small then it will convert into uppercase or visa-versa syntax - text-transform:(uppercase , lowercase , capitalize); 5.Text spacing - It decided the space between letter and words both how many gap are between...

Code of HTML and CSS how we take color , border , etc

  code of HTML and CSS - 1. How we take change color in css (color and border both property) code - <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>color in css</title> <style> .color1{ background-color: green; } .color2{ color: yellow; } .color3{ border: 2px solid red; } </style> </head> <body> <!-- lets take paragarph --> <p class="color1"> In display property if we apply inline-block property on it we can be set their width and height and element was set next to a element in line it not take extra space so in easy word it is work as both block element who's width and height can be changed </p> <p class="color2"> In display property if we apply inline-blo...