Encapsulation the ability of an object to hide its data and methods from the rest of the world. It is one of the fundamental principles of Oops.
The protection involves providing a stable interface which protects the remainder of the program from the implementation (the details that are most likely to change).
Public class Add
{
private void subtract(int x, int y)
{
return x * y;
}
}
…
…
Add obj;
int Result;
Result = obj.subtract(5,10);
Article written by urooj
Object-oriented programming is a programming paradigm that uses objects – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as information hiding, data abstraction, encapsulation, modularity, polymorphism, and inheritance.
In OOPS, we get the power to create objects of our own, as & when required. Oops is a programming methodology where each entity is an object.
Article written by urooj
Classes are the type of objects.
The class is the type of the object,and the object is an instance of the class.You normally create objects using classes,and then use those objects in your code.
Example:–
class Harry
{
var $name;
function set_name($data)
{
global $name;
$name = $data;
}
function get_name()
{
global $name;
return $name;
}
}
In php,classes are usually given names that start whit a capital letter,and objects are given names that start with a lowercase letter.
Article written by urooj